Code
knitr::opts_chunk$set(cache = TRUE)Exploration of dataset
knitr::opts_chunk$set(cache = TRUE)# a vector of all the packages needed in the project
packages_required_in_project <- c("tidyverse",
"readxl",
"RMark",
"RColorBrewer",
"patchwork",
"mapview",
"lubridate",
"extrafont",
"here",
"DT",
"leaflet",
"sf",
"leafpop",
"tsibble",
"corrplot",
"gghalves",
"gam",
"pscl",
"gamlss",
"gt",
"lme4")
# of the required packages, check if some need to be installed
new.packages <-
packages_required_in_project[!(packages_required_in_project %in%
installed.packages()[,"Package"])]
# install all packages that are not locally available
if(length(new.packages)) install.packages(new.packages)
# load all the packages into the current R session
lapply(packages_required_in_project, require, character.only = TRUE)
# set the home directory to where the project is locally based (i.e., to find
# the relevant datasets to import, etc.
here::set_here()# Find fonts from computer that you want. Use regular expressions to do this
# For example, load all fonts that are 'verdana' or 'Verdana'
extrafont::font_import(pattern = "[V/v]erdana", prompt = FALSE)
# check which fonts were loaded
extrafont::fonts()
extrafont::fonttable()
extrafont::loadfonts() # load these into R
# define the plotting theme to be used in subsequent ggplots
luke_theme <-
theme_bw() +
theme(
text = element_text(family = "Verdana"),
legend.title = element_text(size = 10),
legend.text = element_text(size = 8),
axis.title.x = element_text(size = 10),
axis.text.x = element_text(size = 8),
axis.title.y = element_text(size = 10),
axis.text.y = element_text(size = 8),
strip.text = element_text(size = 10),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks = element_line(size = 0.5, colour = "grey40"),
axis.ticks.length = unit(0.2, "cm"),
panel.border = element_rect(linetype = "solid", colour = "grey"),
legend.position = c(0.1, 0.9)
)
region_names <- c(
'FP' = "Fleurieu Peninsula",
'MP' = "Mornington Peninsula",
'BSC' = "Bellarine / Surf Coast")
# set mapview to show satellite imagery
# mapviewOptions(basemaps = c("Esri.WorldImagery"))
# # set plotting color palettes
# sex_pal2 <-
# c(pull(ggthemes_data$wsj$palettes$colors6[3,2]),
# pull(ggthemes_data$wsj$palettes$colors6[2,2]))
#
# sex_pal3 <-
# c(pull(ggthemes_data$wsj$palettes$colors6[3,2]),
# pull(ggthemes_data$wsj$palettes$colors6[3,2]),
# pull(ggthemes_data$wsj$palettes$colors6[2,2]),
# pull(ggthemes_data$wsj$palettes$colors6[2,2]))
#
# # specify the facet labels for each species and sex
# species_names <- c(
# 'BC' = "Black coucal",
# 'WBC' = "White-browed coucal")
#
# sex_names <- c(
# 'female' = "Females",
# 'male' = "Males")
#
# analysis_names <- c(
# 'male' = "Male Mo scenario",
# 'female' = "Female Mo scenario"
# )
#
# # color of mean estimate point in forest plots
# col_all <- "#2E3440"
#
# # custom color palette for the plotting of Juvenile and Adult stats
# cbPalette_LTRE <-
# c("#D9D9D9", "#D9D9D9", "#D9D9D9",
# "#D9D9D9", "#A6A6A6", "#A6A6A6",
# "#A6A6A6")
#
# cbPalette_sex_diff <-
# c("#D9D9D9", "#D9D9D9", "#D9D9D9",
# "#D9D9D9", "#A6A6A6")
#
# # plot the comparative LTRE results
# vital_rate_theme <-
# theme_bw() +
# theme(
# text = element_text(family = "Verdana"),
# legend.position = "none",
# panel.grid.major = element_blank(),
# panel.grid.minor = element_blank(),
# axis.ticks.length = unit(0.1, "cm"),
# panel.border = element_blank(),
# panel.spacing.x = unit(0.3, "lines"),
# panel.spacing.y = unit(0.7, "lines"),
# strip.background = element_blank()
# )
# species.labs <- c("Black Coucal", "White-browed Coucal")
# names(species.labs) <- c("BC", "WBC")The following custom functions are used to
%!in%This function simply does the opposite of %in%, which is used to test if elements on the left-hand side are members of the set defined by the right-hand side. %!in% returns a logical vector indicating whether each element on the left-hand side is not present in the right-hand side.
`%!in%` = Negate(`%in%`)lucinda_nest_import()This function imports the HOPL nest survival data stored as Excel sheets into R, wrangles it into a single dataframe, and prepares it for subsequent analysis (e.g., specifies relevent date columns, etc.)
arguments:
year_1: first calender year of the focal data sheet (e.g., 2002)year_2: second calender year of the focal data set (i.e., always year_1 + 1)file_name: name of the Excel sheet to import data fromsite: site that the data describes (MP, FP, or BSC)extra_text: the extra text associated with each sheet in the Excel file (i.e., besides from the year)first_found_date_col: the number of the column in the sheets that correspond to the first found datelast_alive_date_col: the number of the column in the sheets that correspond to the last alive datelast_checked_col: the number of the column in the sheets that correspond to the last checked datelucinda_nest_import <-
function(year_1, year_2, file_name, site, extra_text = NULL,
first_found_date_col, last_alive_date_col, last_checked_col) {
if(is.null(extra_text)){
file <-
read_excel(paste0("data/final/final_final/final_final_final/", file_name),
sheet = paste0(site, " ", year_1, "_", str_sub(year_2, 3, 4)),
col_types = "text", na = "n/a")
}
else{
file <-
read_excel(paste0("data/final/final_final/final_final_final/", file_name),
sheet = paste0(site, " ", year_1, "_", str_sub(year_2, 3, 4), extra_text),
col_types = "text", na = "n/a")
}
file %>%
# simplify column names
rename(first_found = first_found_date_col,
last_alive = last_alive_date_col,
last_checked = last_checked_col,
Fate = `Hatch?`,
season = Season,
site = Site,
nest_ID = `Nest ID`,
nest_hab = `Nest habitat`,
management_status = `Nest managed?`,
management_type = `Management type`,
nest_lat = `Nest latitude`,
nest_lon = `Nest longitude`) %>%
# consolidate columns
dplyr::select(season, site, nest_ID, first_found, last_alive, last_checked, Fate, nest_hab,
management_status, management_type, nest_lat, nest_lon, site) %>%
# wrangle: clean up Fate column for consistency
mutate(Fate = ifelse(Fate == "?", "Unk", Fate)) %>%
mutate(Fate = toupper(Fate)) %>%
# wrangle: if date last alive is "Unk." make it "NA"
mutate(last_alive = ifelse(str_detect(last_alive, "Unk."), NA, last_alive),
# change Fate to 1 or 0 (1 = failed, 0 = hatched, NA = unknown)
Fate = ifelse(Fate == "Y", 0,
ifelse(Fate == "N", 1,
ifelse(Fate == "UNK", NA, "XXX")))) %>%
mutate(
# wrangle: if last_alive has a date and last_checked is NA, then change
# last_checked to the date in last_alive
last_checked = ifelse(!is.na(last_alive) & is.na(last_checked),
last_alive,
# if both last_alive and last_checked is "NA", then
# change last_checked to the first_found date
ifelse(is.na(last_alive) & is.na(last_checked),
first_found,
last_checked))) %>%
mutate(
# wrangle: if last_alive is NA and the nest hatched and last_checked has a
# date, then specify last_alive as the date from last_checked
last_alive = ifelse(is.na(last_alive) & Fate == "0" & !is.na(last_checked),
last_checked,
# if the last_alive is NA and the nest failed and
# last_checked has a date, then specify last_alive as the
# date from first_found
ifelse(is.na(last_alive) & Fate == "1" & !is.na(last_checked),
first_found,
last_alive))) %>%
filter(nchar(first_found) == 8 & nchar(last_alive) == 8 & nchar(last_checked) == 8) %>%
# specify date columns as a date string
mutate(first_found2 = as.Date(paste(str_sub(first_found, 5, 8),
str_sub(first_found, 3, 4),
str_sub(first_found, 1, 2), sep = "-")),
last_alive2 = as.Date(paste(str_sub(last_alive, 5, 8),
str_sub(last_alive, 3, 4),
str_sub(last_alive, 1, 2), sep = "-")),
last_checked2 = as.Date(paste(str_sub(last_checked, 5, 8),
str_sub(last_checked, 3, 4),
str_sub(last_checked, 1, 2), sep = "-"))) %>%
# if last checked date is before last alive date, then change it to the
# last alive date, if not then leave as is
# mutate(last_checked2 = ifelse(last_checked2 < last_alive2 | (is.na(last_checked2) & !is.na(last_alive2)), last_alive2, last_checked2)) %>%
# julian dates
mutate(FirstFound = as.numeric(format(first_found2 + 180, "%j")),
LastPresent = as.numeric(format(last_alive2 + 180, "%j")),
LastChecked = as.numeric(format(last_checked2 + 180, "%j"))) %>%
# remove all nests that have unknown fate
filter(!is.na(Fate)) %>%
# clean up the management_type column
mutate(management_type = tolower(management_type)) %>%
mutate(management_type = str_replace(management_type, "acess", "access")) %>%
mutate(management_type = str_replace(management_type, "and", ",")) %>%
mutate(management_type = str_replace(management_type, "temporary", "")) %>%
mutate(management_type = str_replace_all(management_type, " ", "")) %>%
mutate(management_type = str_replace_all(management_type, "shelters", "")) %>%
mutate(management_type = str_replace_all(management_type, "banners", "")) %>%
mutate(management_type = str_replace_all(management_type, ",,", ",")) %>%
mutate(sign_access = ifelse(str_detect(management_type, "signaccess"), 1, 0)) %>%
mutate(sign_nest = ifelse(str_detect(management_type, "signnest"), 1, 0)) %>%
mutate(rope_fence = ifelse(str_detect(management_type, "ropefence"), 1, 0)) %>%
mutate(wardens = ifelse(str_detect(management_type, "wardens"), 1, 0)) %>%
mutate(none = ifelse(str_detect(management_type, "none"), 1, 0)) %>%
mutate(other = ifelse(str_detect(management_type, "other"), 1, 0)) %>%
mutate(management_level = ifelse(sign_access == 1 & sign_nest == 1 & rope_fence == 1 & wardens == 1, 4,
ifelse(rope_fence == 1, 3,
ifelse(sign_nest == 1, 2,
ifelse(sign_access == 1, 1,
ifelse(none == 1, 0, NA)))))) %>%
mutate(sign_nest_no_sign_access = ifelse(sign_access == 0 & sign_nest == 1, 1, 0)) %>%
mutate(fence_no_sign = ifelse((sign_access == 0 & sign_nest == 0) & rope_fence == 1, 1, 0)) %>%
mutate(wardens_no_sign = ifelse((sign_access == 0 & sign_nest == 0) & wardens == 1, 1, 0)) %>%
mutate(wardens_no_fence = ifelse(rope_fence == 1 & wardens == 1, 1, 0)) %>%
mutate(just_wardens = ifelse(rope_fence == 0 & sign_access == 0 & sign_nest == 0 & wardens == 1, 1, 0)) %>%
dplyr::select(#-management_type, -sign_access, -sign_nest, -rope_fence,
#-wardens, -none,
-other,
-sign_nest_no_sign_access, -fence_no_sign,
-wardens_no_sign, -wardens_no_fence, -just_wardens) %>%
mutate(site = str_extract(nest_ID, "_([^_]+)_") %>% str_remove_all("_"))
}First we import the data and run a few checks to assess if there are any rows with the following issues:
found date is not 8 characters
last seen alive date is not 8 characters
last checked date is not 8 characters
found date missing
last seen alive date missing
last checked date missing
Nest managed? is not Y or N
Nest habitat is not Beach, Dune, Foredune/face, Estuary/spit, or Rocks
Management type is not sufficient for making levels
Double check dates because incubation time greater than 35 days
Found date is after Last Alive date (should be greater or equal)
Found date is after Last Checked date (should be greater or equal)
Last Checked date is before Last Alive date (should be greater or equal)
suppressMessages(
bind_rows(
read_excel(paste0("data/final/final_final/final_final_final/", "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("MP", " ", "2020", "_", str_sub("2021", 3, 4)),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("MP", " ", "2019", "_", str_sub("2020", 3, 4)),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("MP", " ", "2018", "_", str_sub("2019", 3, 4)),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("MP", " ", "2017", "_", str_sub("2018", 3, 4)),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("MP", " ", "2016", "_", str_sub("2017", 3, 4)),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("MP", " ", "2015", "_", str_sub("2016", 3, 4)),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("MP", " ", "2014", "_", str_sub("2015", 3, 4)),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("MP", " ", "2013", "_", str_sub("2014", 3, 4)),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("MP", " ", "2012", "_", str_sub("2013", 3, 4)),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("MP", " ", "2011", "_", str_sub("2012", 3, 4)),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("MP", " ", "2010", "_", str_sub("2011", 3, 4)),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("MP", " ", "2009", "_", str_sub("2010", 3, 4)),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("MP", " ", "2008", "_", str_sub("2009", 3, 4)),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("MP", " ", "2007", "_", str_sub("2008", 3, 4)),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("MP", " ", "2006", "_", str_sub("2007", 3, 4)),
col_types = "text", na = "n/a"))) %>%
filter(!is.na(Season)) %>%
rename(first_found = 10,
last_alive = 27,
last_checked = 32,
Fate = `Hatch?`,
season = Season,
site = Site,
nest_ID = `Nest ID`,
nest_hab = `Nest habitat`,
management_status = `Nest managed?`,
management_type = `Management type`,
nest_lat = `Nest latitude`,
nest_lon = `Nest longitude`) %>%
dplyr::select(season, site, nest_ID, first_found, last_alive, last_checked, Fate, nest_hab,
management_status, management_type, nest_lat, nest_lon, site) %>%
mutate(Fate = ifelse(Fate == "?", "Unk", Fate)) %>%
mutate(Fate = toupper(Fate)) %>%
mutate(last_alive = ifelse(str_detect(last_alive, "Unk."), NA, last_alive),
Fate = ifelse(Fate == "Y", 0,
ifelse(Fate == "N", 1,
ifelse(Fate == "UNK", NA, "XXX")))) %>%
mutate(
last_checked = ifelse(!is.na(last_alive) & is.na(last_checked),
last_alive,
ifelse(is.na(last_alive) & is.na(last_checked),
first_found,
last_checked))) %>%
mutate(
last_alive = ifelse(is.na(last_alive) & Fate == "0" & !is.na(last_checked),
last_checked,
ifelse(is.na(last_alive) & Fate == "1" & !is.na(last_checked),
first_found,
last_alive))) %>%
mutate(first_found2 = as.Date(paste(str_sub(first_found, 5, 8),
str_sub(first_found, 3, 4),
str_sub(first_found, 1, 2), sep = "-")),
last_alive2 = as.Date(paste(str_sub(last_alive, 5, 8),
str_sub(last_alive, 3, 4),
str_sub(last_alive, 1, 2), sep = "-")),
last_checked2 = as.Date(paste(str_sub(last_checked, 5, 8),
str_sub(last_checked, 3, 4),
str_sub(last_checked, 1, 2), sep = "-"))) %>%
mutate(FirstFound = as.numeric(format(first_found2 + 180, "%j")),
LastPresent = as.numeric(format(last_alive2 + 180, "%j")),
LastChecked = as.numeric(format(last_checked2 + 180, "%j"))) %>%
mutate(management_type = tolower(management_type)) %>%
mutate(management_type = str_replace(management_type, "acess", "access")) %>%
mutate(management_type = str_replace(management_type, "and", ",")) %>%
mutate(management_type = str_replace(management_type, "temporary", "")) %>%
mutate(management_type = str_replace_all(management_type, " ", "")) %>%
mutate(management_type = str_replace_all(management_type, "shelters", "")) %>%
mutate(management_type = str_replace_all(management_type, "banners", "")) %>%
mutate(management_type = str_replace_all(management_type, ",,", ",")) %>%
mutate(sign_access = ifelse(str_detect(management_type, "signaccess"), 1, 0)) %>%
mutate(sign_nest = ifelse(str_detect(management_type, "signnest"), 1, 0)) %>%
mutate(rope_fence = ifelse(str_detect(management_type, "ropefence"), 1, 0)) %>%
mutate(wardens = ifelse(str_detect(management_type, "wardens"), 1, 0)) %>%
mutate(none = ifelse(str_detect(management_type, "none"), 1, 0)) %>%
mutate(other = ifelse(str_detect(management_type, "other"), 1, 0)) %>%
mutate(management_level = ifelse(sign_access == 1 & sign_nest == 1 & rope_fence == 1 & wardens == 1, 4,
ifelse(rope_fence == 1, 3,
ifelse(sign_nest == 1, 2,
ifelse(sign_access == 1, 1,
ifelse(none == 1, 0, NA)))))) %>%
mutate(sign_nest_no_sign_access = ifelse(sign_access == 0 & sign_nest == 1, 1, 0)) %>%
mutate(fence_no_sign = ifelse((sign_access == 0 & sign_nest == 0) & rope_fence == 1, 1, 0)) %>%
mutate(wardens_no_sign = ifelse((sign_access == 0 & sign_nest == 0) & wardens == 1, 1, 0)) %>%
mutate(wardens_no_fence = ifelse(rope_fence == 1 & wardens == 1, 1, 0)) %>%
mutate(just_wardens = ifelse(rope_fence == 0 & sign_access == 0 & sign_nest == 0 & wardens == 1, 1, 0)) %>%
dplyr::select(-other, -sign_nest_no_sign_access, -fence_no_sign,
-wardens_no_sign, -wardens_no_fence, -just_wardens) %>%
group_by(season) %>%
mutate(nocc = max(max(LastChecked, na.rm = TRUE), max(LastPresent, na.rm = TRUE)),
season = as.factor(season),
nest_hab = as.factor(nest_hab),
management_status = as.factor(management_status)) %>%
mutate(region = "MP") %>%
mutate(site = as.factor(site)) %>%
mutate(issue1 = ifelse(nchar(first_found) != 8, "found date is not 8 characters; ", NA)) %>%
mutate(issue2 = ifelse(nchar(last_alive) != 8, "last seen alive date is not 8 characters; ", NA)) %>%
mutate(issue3 = ifelse(nchar(last_checked) != 8, "last checked date is not 8 characters; ", NA)) %>%
mutate(issue4 = ifelse(is.na(first_found), "found date missing; ", NA)) %>%
mutate(issue5 = ifelse(is.na(last_alive), "last seen alive date missing; ", NA)) %>%
mutate(issue6 = ifelse(is.na(last_checked), "last checked date missing; ", NA)) %>%
mutate(issue7 = ifelse(management_status %!in% c("Y", "N"), "Nest managed? is not Y or N; ", NA)) %>%
mutate(issue8 = ifelse(nest_hab %!in% c("Beach", "Dune", "Foredune/face", "Estuary/spit", "Rocks"), "Nest habitat is not Beach, Dune, Foredune/face, Estuary/spit, or Rocks; ", NA)) %>%
mutate(issue9 = ifelse(is.na(management_level), "Management type is not sufficient for making levels; ", NA)) %>%
mutate(found_and_alive_diff = last_alive2 - first_found2) %>%
mutate(issue10 = ifelse(found_and_alive_diff > 35 , "Double check dates because incubation time greater than 35 days; ", NA)) %>%
mutate(issue11 = ifelse(FirstFound > LastPresent, "Found date is after Last Alive date (should be greater or equal); ", NA)) %>%
mutate(issue12 = ifelse(FirstFound > LastChecked, "Found date is after Last Checked date (should be greater or equal); ", NA)) %>%
mutate(issue13 = ifelse(LastChecked < LastPresent, "Last Checked date is before Last Alive date (should be greater or equal); ", NA)) %>%
mutate(issues = ifelse(is.na(issue1) & is.na(issue2) & is.na(issue3) &
is.na(issue4) & is.na(issue5) & is.na(issue6) &
is.na(issue7) & is.na(issue8) & is.na(issue9) &
is.na(issue10) & is.na(issue11) & is.na(issue12) & is.na(issue13), NA,
paste0(issue1, issue2, issue3,
issue4, issue5, issue6,
issue7, issue8, issue9,
issue10, issue11, issue12, issue13))) %>%
mutate(issues = str_remove_all(issues, "NA")) %>%
mutate(issues = ifelse(is.na(issues), "usable", issues)) %>%
dplyr::select(-issue1, -issue2, -issue3,
-issue4, -issue5, -issue6,
-issue7, -issue8, -issue9,
-issue10, -issue11, -issue12, -issue13) %>%
filter(issues != "usable") %>%
arrange(issues) %>%
filter(first_found != "Not found" & last_alive != "Not seen" & last_checked != "Not seen" & last_checked != "Not revisited") %>%
filter(str_detect(issues, "date")) %>%
mutate(issues = str_remove_all(issues, "Management type is not sufficient for making levels; ")) %>%
mutate(issues = str_remove_all(issues, "Nest habitat is not Beach, Dune, Foredune/face, Estuary/spit, or Rocks; ")) %>%
dplyr::select(season, nest_ID, first_found, first_found2, last_alive, last_alive2, last_checked, last_checked2, Fate, found_and_alive_diff, issues) %>%
datatable(class = 'cell-border stripe', rownames = FALSE, filter = 'top') # write_csv(., "data/final/final_final/final_final_final/nest_issues_commented/MP Nesting Summary 2020_21 to 2006_07 site names match threat data_nests_w_issues_commented.csv", col_names = TRUE, append = FALSE, quote = "all")nest_data_MP <-
bind_rows(
lucinda_nest_import(year_1 = "2020", year_2 = "2021",
file_name = "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx", site = "MP",
first_found_date_col = 10,
last_alive_date_col = 27,
last_checked_col = 32),
lucinda_nest_import(year_1 = "2019", year_2 = "2020",
file_name = "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx", site = "MP",
first_found_date_col = 10,
last_alive_date_col = 27,
last_checked_col = 32),
lucinda_nest_import(year_1 = "2018", year_2 = "2019",
file_name = "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx", site = "MP",
first_found_date_col = 10,
last_alive_date_col = 27,
last_checked_col = 32),
lucinda_nest_import(year_1 = "2017", year_2 = "2018",
file_name = "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx", site = "MP",
first_found_date_col = 10,
last_alive_date_col = 27,
last_checked_col = 32),
lucinda_nest_import(year_1 = "2016", year_2 = "2017",
file_name = "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx", site = "MP",
first_found_date_col = 10,
last_alive_date_col = 27,
last_checked_col = 32),
lucinda_nest_import(year_1 = "2015", year_2 = "2016",
file_name = "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx", site = "MP",
first_found_date_col = 10,
last_alive_date_col = 27,
last_checked_col = 32),
lucinda_nest_import(year_1 = "2014", year_2 = "2015",
file_name = "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx", site = "MP",
first_found_date_col = 10,
last_alive_date_col = 27,
last_checked_col = 32),
lucinda_nest_import(year_1 = "2013", year_2 = "2014",
file_name = "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx", site = "MP",
first_found_date_col = 10,
last_alive_date_col = 27,
last_checked_col = 32),
lucinda_nest_import(year_1 = "2012", year_2 = "2013",
file_name = "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx", site = "MP",
first_found_date_col = 10,
last_alive_date_col = 27,
last_checked_col = 32),
lucinda_nest_import(year_1 = "2011", year_2 = "2012",
file_name = "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx", site = "MP",
first_found_date_col = 10,
last_alive_date_col = 27,
last_checked_col = 32),
lucinda_nest_import(year_1 = "2010", year_2 = "2011",
file_name = "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx", site = "MP",
first_found_date_col = 10,
last_alive_date_col = 27,
last_checked_col = 32),
lucinda_nest_import(year_1 = "2009", year_2 = "2010",
file_name = "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx", site = "MP",
first_found_date_col = 10,
last_alive_date_col = 27,
last_checked_col = 32),
lucinda_nest_import(year_1 = "2008", year_2 = "2009",
file_name = "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx", site = "MP",
first_found_date_col = 10,
last_alive_date_col = 27,
last_checked_col = 32),
lucinda_nest_import(year_1 = "2007", year_2 = "2008",
file_name = "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx", site = "MP",
first_found_date_col = 10,
last_alive_date_col = 27,
last_checked_col = 32),
lucinda_nest_import(year_1 = "2006", year_2 = "2007",
file_name = "MP Nesting Summary 2020_21 to 2006_07 fix ups post email from Luke 27_2_24.xlsx", site = "MP",
first_found_date_col = 10,
last_alive_date_col = 27,
last_checked_col = 32)) %>%
group_by(season) %>%
mutate(nocc = max(max(LastChecked, na.rm = TRUE), max(LastPresent, na.rm = TRUE)),
season = as.factor(season),
nest_hab = as.factor(nest_hab),
management_status = as.factor(management_status)) %>%
filter(!is.na(FirstFound) & !is.na(LastPresent) & !is.na(LastChecked)) %>%
filter(management_status %in% c("Y", "N")) %>%
filter(nest_hab %in% c("Beach", "Dune", "Foredune/face", "Estuary/spit", "Rocks")) %>%
filter(!is.na(management_level)) %>%
mutate(region = "MP") %>%
mutate(site = as.factor(site)) %>%
ungroup()nest_data_MP_check <-
nest_data_MP %>%
ungroup() %>%
mutate(first_found2_md = paste(format(first_found2 + 180, format = "%m"),
format(first_found2 + 180, format = "%d"),
sep = "-"),
last_alive2_md = paste(format(last_alive2 + 180, format = "%m"),
format(last_alive2 + 180, format = "%d"),
sep = "-"),
last_checked2_md = paste(format(last_checked2 + 180, format = "%m"),
format(last_checked2 + 180, format = "%d"),
sep = "-")) %>%
mutate(first_found2_trans = as.Date(paste("2020", first_found2_md, sep = "-"), format = "%Y-%m-%d") - 179,
last_alive2_trans = as.Date(paste("2020", last_alive2_md, sep = "-"), format = "%Y-%m-%d") - 179,
last_checked2_trans = as.Date(paste("2020", last_checked2_md, sep = "-"), format = "%Y-%m-%d") - 179) %>%
mutate(season_label = paste0("season ", str_sub(season, 1, 4), " to ", str_sub(season, 5, 6)),
Fate = as.factor(Fate))Note that this map only shows data that are in a decimal degrees format (e.g., -38.31), NOT degree minute seconds (e.g., 38 27.59). The map is interactive, so click on an outlier to see its metadata
nest_data_MP %>%
mutate(nest_lon = as.numeric(nest_lon),
nest_lat = as.numeric(nest_lat)) %>%
filter(!is.na(nest_lon) & !is.na(nest_lat)) %>%
st_as_sf(coords = c("nest_lon", "nest_lat"),
crs = 4326) %>%
mapview(popup = popupTable(.,
zcol = c("season",
"site",
"nest_ID")))ggplot(nest_data_MP_check, aes(first_found2_trans, fill = Fate)) +
geom_histogram(bins = 30,
alpha = 0.8, color = "white", linewidth = 0.2) +
scale_fill_manual(values = c("1" = brewer.pal(8, "Set1")[c(1)], "0" = brewer.pal(8, "Set1")[c(2)]),
name = "Nest Fate",
labels = c("Hatched", "Failed")) +
ylab("weekly number of nests") +
scale_x_date(date_labels = "%B",
expand = c(0.01, 0.01),
date_breaks = "1 months", limits = c(min(nest_data_MP_check$first_found2_trans, na.rm = TRUE),
max(nest_data_MP_check$last_checked2_trans, na.rm = TRUE))) +
facet_wrap("season_label") +
scale_y_continuous(limits = c(0, 12), breaks = c(2, 4, 6, 8, 10, 12)) +
luke_theme +
xlab("Found date") +
theme(legend.position = "top",
panel.grid.major = element_line(colour = "grey70",
size = 0.15),
axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5))ggplot(nest_data_MP_check, aes(last_alive2_trans, fill = as.factor(Fate))) +
geom_histogram(bins = 30,
alpha = 0.8, color = "white", linewidth = 0.2) +
scale_fill_manual(values = c("1" = brewer.pal(8, "Set1")[c(1)], "0" = brewer.pal(8, "Set1")[c(2)]),
name = "Nest Fate",
labels = c("Hatched", "Failed")) +
ylab("weekly number of nests") +
scale_x_date(date_labels = "%B",
expand = c(0.01, 0.01),
date_breaks = "1 months", limits = c(min(nest_data_MP_check$first_found2_trans, na.rm = TRUE),
max(nest_data_MP_check$last_checked2_trans, na.rm = TRUE))) +
facet_wrap("season_label") +
scale_y_continuous(limits = c(0, 12), breaks = c(2, 4, 6, 8, 10, 12)) +
luke_theme +
xlab("Last alive date") +
theme(legend.position = "top",
panel.grid.major = element_line(colour = "grey70",
size = 0.15),
axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5)) ggplot(nest_data_MP_check, aes(last_checked2_trans, fill = as.factor(Fate))) +
geom_histogram(bins = 30,
alpha = 0.8, color = "white", linewidth = 0.2) +
scale_fill_manual(values = c("1" = brewer.pal(8, "Set1")[c(1)], "0" = brewer.pal(8, "Set1")[c(2)]),
name = "Nest Fate",
labels = c("Hatched", "Failed")) +
ylab("weekly number of nests") +
scale_x_date(date_labels = "%B",
expand = c(0.01, 0.01),
date_breaks = "1 months", limits = c(min(nest_data_MP_check$first_found2_trans, na.rm = TRUE),
max(nest_data_MP_check$last_checked2_trans, na.rm = TRUE))) +
facet_wrap("season_label") +
scale_y_continuous(limits = c(0, 12), breaks = c(2, 4, 6, 8, 10, 12)) +
luke_theme +
xlab("Last checked date") +
theme(legend.position = "top",
panel.grid.major = element_line(colour = "grey70",
size = 0.15),
axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5))# assess if there are nests with unusually long incubation periods
nest_data_MP_check %>%
mutate(found_and_alive_diff = last_alive2 - first_found2) %>%
arrange(desc(found_and_alive_diff)) %>%
filter(first_found2 < last_alive2 & first_found2 < last_checked2 & found_and_alive_diff < 100) %>%
ggplot() +
geom_histogram(aes(found_and_alive_diff)) +
luke_theme +
xlab("Time between found date and last alive date (days)") +
ylab("Frquency of nests")# A tibble: 0 × 26
# ℹ 26 variables: season <fct>, site <fct>, nest_ID <chr>, first_found <chr>,
# last_alive <chr>, last_checked <chr>, Fate <chr>, nest_hab <fct>,
# management_status <fct>, management_type <chr>, nest_lat <chr>,
# nest_lon <chr>, first_found2 <date>, last_alive2 <date>,
# last_checked2 <date>, FirstFound <dbl>, LastPresent <dbl>,
# LastChecked <dbl>, sign_access <dbl>, sign_nest <dbl>, rope_fence <dbl>,
# wardens <dbl>, none <dbl>, management_level <dbl>, nocc <dbl>, …
# A tibble: 0 × 26
# ℹ 26 variables: season <fct>, site <fct>, nest_ID <chr>, first_found <chr>,
# last_alive <chr>, last_checked <chr>, Fate <chr>, nest_hab <fct>,
# management_status <fct>, management_type <chr>, nest_lat <chr>,
# nest_lon <chr>, first_found2 <date>, last_alive2 <date>,
# last_checked2 <date>, FirstFound <dbl>, LastPresent <dbl>,
# LastChecked <dbl>, sign_access <dbl>, sign_nest <dbl>, rope_fence <dbl>,
# wardens <dbl>, none <dbl>, management_level <dbl>, nocc <dbl>, …
# A tibble: 1 × 26
season site nest_ID first_found last_alive last_checked Fate nest_hab
<fct> <fct> <chr> <chr> <chr> <chr> <chr> <fct>
1 201516 Koonya East 201516_… 17012016 15022016 16012016 0 Foredun…
# ℹ 18 more variables: management_status <fct>, management_type <chr>,
# nest_lat <chr>, nest_lon <chr>, first_found2 <date>, last_alive2 <date>,
# last_checked2 <date>, FirstFound <dbl>, LastPresent <dbl>,
# LastChecked <dbl>, sign_access <dbl>, sign_nest <dbl>, rope_fence <dbl>,
# wardens <dbl>, none <dbl>, management_level <dbl>, nocc <dbl>, region <chr>
As above, first we import the data and run a few checks to assess if there are any rows with the issues listed above
suppressMessages(bind_rows(
read_excel(paste0("data/final/final_final/final_final_final/", "FP Nesting summary 2020_21 to 2009_10 FINAL- no changes made post email from luke 27_2_24.xlsx"),
sheet = paste0("FP", " ", "2020", "_", str_sub("2021", 3, 4), " Nest summary"),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "FP Nesting summary 2020_21 to 2009_10 FINAL- no changes made post email from luke 27_2_24.xlsx"),
sheet = paste0("FP", " ", "2019", "_", str_sub("2020", 3, 4), " Nest summary"),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "FP Nesting summary 2020_21 to 2009_10 FINAL- no changes made post email from luke 27_2_24.xlsx"),
sheet = paste0("FP", " ", "2018", "_", str_sub("2019", 3, 4), " Nest summary"),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "FP Nesting summary 2020_21 to 2009_10 FINAL- no changes made post email from luke 27_2_24.xlsx"),
sheet = paste0("FP", " ", "2017", "_", str_sub("2018", 3, 4), " Nest summary"),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "FP Nesting summary 2020_21 to 2009_10 FINAL- no changes made post email from luke 27_2_24.xlsx"),
sheet = paste0("FP", " ", "2016", "_", str_sub("2017", 3, 4), " Nest summary"),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "FP Nesting summary 2020_21 to 2009_10 FINAL- no changes made post email from luke 27_2_24.xlsx"),
sheet = paste0("FP", " ", "2015", "_", str_sub("2016", 3, 4), " Nest summary"),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "FP Nesting summary 2020_21 to 2009_10 FINAL- no changes made post email from luke 27_2_24.xlsx"),
sheet = paste0("FP", " ", "2014", "_", str_sub("2015", 3, 4), " Nest summary"),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "FP Nesting summary 2020_21 to 2009_10 FINAL- no changes made post email from luke 27_2_24.xlsx"),
sheet = paste0("FP", " ", "2013", "_", str_sub("2014", 3, 4), " Nest summary"),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "FP Nesting summary 2020_21 to 2009_10 FINAL- no changes made post email from luke 27_2_24.xlsx"),
sheet = paste0("FP", " ", "2012", "_", str_sub("2013", 3, 4), " Nest summary"),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "FP Nesting summary 2020_21 to 2009_10 FINAL- no changes made post email from luke 27_2_24.xlsx"),
sheet = paste0("FP", " ", "2011", "_", str_sub("2012", 3, 4), " Nest summary"),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "FP Nesting summary 2020_21 to 2009_10 FINAL- no changes made post email from luke 27_2_24.xlsx"),
sheet = paste0("FP", " ", "2010", "_", str_sub("2011", 3, 4), " Nest summary"),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "FP Nesting summary 2020_21 to 2009_10 FINAL- no changes made post email from luke 27_2_24.xlsx"),
sheet = paste0("FP", " ", "2009", "_", str_sub("2010", 3, 4), " Nest summary"),
col_types = "text", na = "n/a"))) %>%
rename(first_found = 10,
last_alive = 29,
last_checked = 36,
Fate = `Hatch?`,
season = Season,
site = Site,
nest_ID = `Nest ID`,
nest_hab = `Nest habitat`,
management_status = `Nest managed?`,
management_type = `Management type`,
nest_lat = `Nest latitude`,
nest_lon = `Nest longitude`) %>%
dplyr::select(season, site, nest_ID, first_found, last_alive, last_checked, Fate, nest_hab,
management_status, management_type, nest_lat, nest_lon, site) %>%
mutate(Fate = ifelse(Fate == "?", "Unk", Fate)) %>%
mutate(Fate = toupper(Fate)) %>%
mutate(last_alive = ifelse(str_detect(last_alive, "Unk."), NA, last_alive),
Fate = ifelse(Fate == "Y", 0,
ifelse(Fate == "N", 1,
ifelse(Fate == "UNK", NA, "XXX")))) %>%
mutate(
last_checked = ifelse(!is.na(last_alive) & is.na(last_checked),
last_alive,
ifelse(is.na(last_alive) & is.na(last_checked),
first_found,
last_checked))) %>%
mutate(
last_alive = ifelse(is.na(last_alive) & Fate == "0" & !is.na(last_checked),
last_checked,
ifelse(is.na(last_alive) & Fate == "1" & !is.na(last_checked),
first_found,
last_alive))) %>%
mutate(first_found2 = as.Date(paste(str_sub(first_found, 5, 8),
str_sub(first_found, 3, 4),
str_sub(first_found, 1, 2), sep = "-")),
last_alive2 = as.Date(paste(str_sub(last_alive, 5, 8),
str_sub(last_alive, 3, 4),
str_sub(last_alive, 1, 2), sep = "-")),
last_checked2 = as.Date(paste(str_sub(last_checked, 5, 8),
str_sub(last_checked, 3, 4),
str_sub(last_checked, 1, 2), sep = "-"))) %>%
mutate(FirstFound = as.numeric(format(first_found2 + 180, "%j")),
LastPresent = as.numeric(format(last_alive2 + 180, "%j")),
LastChecked = as.numeric(format(last_checked2 + 180, "%j"))) %>%
mutate(management_type = tolower(management_type)) %>%
mutate(management_type = str_replace(management_type, "acess", "access")) %>%
mutate(management_type = str_replace(management_type, "and", ",")) %>%
mutate(management_type = str_replace(management_type, "temporary", "")) %>%
mutate(management_type = str_replace_all(management_type, " ", "")) %>%
mutate(management_type = str_replace_all(management_type, "shelters", "")) %>%
mutate(management_type = str_replace_all(management_type, "banners", "")) %>%
mutate(management_type = str_replace_all(management_type, ",,", ",")) %>%
mutate(sign_access = ifelse(str_detect(management_type, "signaccess"), 1, 0)) %>%
mutate(sign_nest = ifelse(str_detect(management_type, "signnest"), 1, 0)) %>%
mutate(rope_fence = ifelse(str_detect(management_type, "ropefence"), 1, 0)) %>%
mutate(wardens = ifelse(str_detect(management_type, "wardens"), 1, 0)) %>%
mutate(none = ifelse(str_detect(management_type, "none"), 1, 0)) %>%
mutate(other = ifelse(str_detect(management_type, "other"), 1, 0)) %>%
mutate(management_level = ifelse(sign_access == 1 & sign_nest == 1 & rope_fence == 1 & wardens == 1, 4,
ifelse(rope_fence == 1, 3,
ifelse(sign_nest == 1, 2,
ifelse(sign_access == 1, 1,
ifelse(none == 1, 0, NA)))))) %>%
mutate(sign_nest_no_sign_access = ifelse(sign_access == 0 & sign_nest == 1, 1, 0)) %>%
mutate(fence_no_sign = ifelse((sign_access == 0 & sign_nest == 0) & rope_fence == 1, 1, 0)) %>%
mutate(wardens_no_sign = ifelse((sign_access == 0 & sign_nest == 0) & wardens == 1, 1, 0)) %>%
mutate(wardens_no_fence = ifelse(rope_fence == 1 & wardens == 1, 1, 0)) %>%
mutate(just_wardens = ifelse(rope_fence == 0 & sign_access == 0 & sign_nest == 0 & wardens == 1, 1, 0)) %>%
dplyr::select(-other, -sign_nest_no_sign_access, -fence_no_sign,
-wardens_no_sign, -wardens_no_fence, -just_wardens) %>%
group_by(season) %>%
mutate(nocc = max(max(LastChecked, na.rm = TRUE), max(LastPresent, na.rm = TRUE)),
season = as.factor(season),
nest_hab = as.factor(nest_hab),
management_status = as.factor(management_status)) %>%
mutate(region = "FP") %>%
mutate(site = as.factor(site)) %>%
mutate(issue1 = ifelse(nchar(first_found) != 8, "found date is not 8 characters; ", NA)) %>%
mutate(issue2 = ifelse(nchar(last_alive) != 8, "last seen alive date is not 8 characters; ", NA)) %>%
mutate(issue3 = ifelse(nchar(last_checked) != 8, "last checked date is not 8 characters; ", NA)) %>%
mutate(issue4 = ifelse(is.na(first_found), "found date missing; ", NA)) %>%
mutate(issue5 = ifelse(is.na(last_alive), "last seen alive date missing; ", NA)) %>%
mutate(issue6 = ifelse(is.na(last_checked), "last checked date missing; ", NA)) %>%
mutate(issue7 = ifelse(management_status %!in% c("Y", "N"), "Nest managed? is not Y or N; ", NA)) %>%
mutate(issue8 = ifelse(nest_hab %!in% c("Beach", "Dune", "Foredune/face", "Estuary/spit", "Rocks"), "Nest habitat is not Beach, Dune, Foredune/face, Estuary/spit, or Rocks; ", NA)) %>%
mutate(issue9 = ifelse(is.na(management_level), "Management type is not sufficient for making levels; ", NA)) %>%
mutate(found_and_alive_diff = last_alive2 - first_found2) %>%
mutate(issue10 = ifelse(found_and_alive_diff > 35 , "Double check dates because incubation time greater than 35 days; ", NA)) %>%
mutate(issue11 = ifelse(FirstFound > LastPresent, "Found date is after Last Alive date (should be greater or equal); ", NA)) %>%
mutate(issue12 = ifelse(FirstFound > LastChecked, "Found date is after Last Checked date (should be greater or equal); ", NA)) %>%
mutate(issue13 = ifelse(LastChecked < LastPresent, "Last Checked date is before Last Alive date (should be greater or equal); ", NA)) %>%
mutate(issues = ifelse(is.na(issue1) & is.na(issue2) & is.na(issue3) &
is.na(issue4) & is.na(issue5) & is.na(issue6) &
is.na(issue7) & is.na(issue8) & is.na(issue9) &
is.na(issue10) & is.na(issue11) & is.na(issue12) & is.na(issue13), NA,
paste0(issue1, issue2, issue3,
issue4, issue5, issue6,
issue7, issue8, issue9,
issue10, issue11, issue12, issue13))) %>%
mutate(issues = str_remove_all(issues, "NA")) %>%
mutate(issues = ifelse(is.na(issues), "usable", issues)) %>%
dplyr::select(-issue1, -issue2, -issue3,
-issue4, -issue5, -issue6,
-issue7, -issue8, -issue9,
-issue10, -issue11, -issue12, -issue13) %>%
filter(issues != "usable") %>%
arrange(issues) %>%
filter(first_found != "Not found" & last_alive != "Not seen" & last_checked != "Not seen" & last_checked != "Not revisited" & last_checked != "Not revisted") %>%
filter(str_detect(issues, "date")) %>%
mutate(issues = str_remove_all(issues, "Management type is not sufficient for making levels; ")) %>%
dplyr::select(season, nest_ID, first_found, first_found2, last_alive, last_alive2, last_checked, last_checked2, Fate, found_and_alive_diff, issues) %>%
datatable(class = 'cell-border stripe', rownames = FALSE, filter = 'top')#%>% # write_csv(., "data/final/final_final/final_final_final/nest_issues_commented/FP Nesting summary 2020_21 to 2009_10 FINAL- checking names consistent for threat data_nests_w_issues_commented.csv", col_names = TRUE, append = FALSE, quote = "all")nest_data_FP <-
bind_rows(
lucinda_nest_import(year_1 = "2020", year_2 = "2021",
file_name = "FP Nesting summary 2020_21 to 2009_10 FINAL- no changes made post email from luke 27_2_24.xlsx", site = "FP", extra_text = " Nest summary",
first_found_date_col = 10,
last_alive_date_col = 29,
last_checked_col = 36),
lucinda_nest_import(year_1 = "2019", year_2 = "2020",
file_name = "FP Nesting summary 2020_21 to 2009_10 FINAL- no changes made post email from luke 27_2_24.xlsx", site = "FP", extra_text = " Nest summary",
first_found_date_col = 10,
last_alive_date_col = 29,
last_checked_col = 36),
lucinda_nest_import(year_1 = "2018", year_2 = "2019",
file_name = "FP Nesting summary 2020_21 to 2009_10 FINAL- no changes made post email from luke 27_2_24.xlsx", site = "FP", extra_text = " Nest summary",
first_found_date_col = 10,
last_alive_date_col = 29,
last_checked_col = 36),
lucinda_nest_import(year_1 = "2017", year_2 = "2018",
file_name = "FP Nesting summary 2020_21 to 2009_10 FINAL- no changes made post email from luke 27_2_24.xlsx", site = "FP", extra_text = " Nest summary",
first_found_date_col = 10,
last_alive_date_col = 29,
last_checked_col = 36),
lucinda_nest_import(year_1 = "2016", year_2 = "2017",
file_name = "FP Nesting summary 2020_21 to 2009_10 FINAL- no changes made post email from luke 27_2_24.xlsx", site = "FP", extra_text = " Nest summary",
first_found_date_col = 10,
last_alive_date_col = 29,
last_checked_col = 36),
lucinda_nest_import(year_1 = "2015", year_2 = "2016",
file_name = "FP Nesting summary 2020_21 to 2009_10 FINAL- no changes made post email from luke 27_2_24.xlsx", site = "FP", extra_text = " Nest summary",
first_found_date_col = 10,
last_alive_date_col = 29,
last_checked_col = 36),
lucinda_nest_import(year_1 = "2014", year_2 = "2015",
file_name = "FP Nesting summary 2020_21 to 2009_10 FINAL- no changes made post email from luke 27_2_24.xlsx", site = "FP", extra_text = " Nest summary",
first_found_date_col = 10,
last_alive_date_col = 29,
last_checked_col = 36),
lucinda_nest_import(year_1 = "2013", year_2 = "2014",
file_name = "FP Nesting summary 2020_21 to 2009_10 FINAL- no changes made post email from luke 27_2_24.xlsx", site = "FP", extra_text = " Nest summary",
first_found_date_col = 10,
last_alive_date_col = 29,
last_checked_col = 36),
lucinda_nest_import(year_1 = "2012", year_2 = "2013",
file_name = "FP Nesting summary 2020_21 to 2009_10 FINAL- no changes made post email from luke 27_2_24.xlsx", site = "FP", extra_text = " Nest summary",
first_found_date_col = 10,
last_alive_date_col = 29,
last_checked_col = 36),
lucinda_nest_import(year_1 = "2011", year_2 = "2012",
file_name = "FP Nesting summary 2020_21 to 2009_10 FINAL- no changes made post email from luke 27_2_24.xlsx", site = "FP", extra_text = " Nest summary",
first_found_date_col = 10,
last_alive_date_col = 29,
last_checked_col = 36),
lucinda_nest_import(year_1 = "2010", year_2 = "2011",
file_name = "FP Nesting summary 2020_21 to 2009_10 FINAL- no changes made post email from luke 27_2_24.xlsx", site = "FP", extra_text = " Nest summary",
first_found_date_col = 10,
last_alive_date_col = 29,
last_checked_col = 36),
lucinda_nest_import(year_1 = "2009", year_2 = "2010",
file_name = "FP Nesting summary 2020_21 to 2009_10 FINAL- no changes made post email from luke 27_2_24.xlsx", site = "FP", extra_text = " Nest summary",
first_found_date_col = 10,
last_alive_date_col = 29,
last_checked_col = 36)) %>%
group_by(season) %>%
mutate(nocc = max(max(LastChecked, na.rm = TRUE), max(LastPresent, na.rm = TRUE)),
season = as.factor(season),
nest_hab = as.factor(nest_hab),
management_status = as.factor(management_status)) %>%
filter(!is.na(FirstFound) & !is.na(LastPresent) & !is.na(LastChecked)) %>%
filter(management_status %in% c("Y", "N")) %>%
filter(nest_hab %in% c("Beach", "Dune", "Foredune/face")) %>%
filter(!is.na(management_level)) %>%
mutate(region = "FP") %>%
mutate(site = as.factor(site))nest_data_FP_check <-
nest_data_FP %>%
ungroup() %>%
mutate(first_found2_md = paste(format(first_found2 + 180, format = "%m"),
format(first_found2 + 180, format = "%d"),
sep = "-"),
last_alive2_md = paste(format(last_alive2 + 180, format = "%m"),
format(last_alive2 + 180, format = "%d"),
sep = "-"),
last_checked2_md = paste(format(last_checked2 + 180, format = "%m"),
format(last_checked2 + 180, format = "%d"),
sep = "-")) %>%
mutate(first_found2_trans = as.Date(paste("2020", first_found2_md, sep = "-"), format = "%Y-%m-%d") - 179,
last_alive2_trans = as.Date(paste("2020", last_alive2_md, sep = "-"), format = "%Y-%m-%d") - 179,
last_checked2_trans = as.Date(paste("2020", last_checked2_md, sep = "-"), format = "%Y-%m-%d") - 179) %>%
mutate(season_label = paste0("season ", str_sub(season, 1, 4), " to ", str_sub(season, 5, 6)))Note that this map only shows data that are in a decimal degrees format (e.g., -38.31), NOT degree minute seconds (e.g., 38 27.59). The map is interactive, so click on an outlier to see its metadata
nest_data_FP %>%
mutate(nest_lon = as.numeric(nest_lon),
nest_lat = as.numeric(nest_lat)) %>%
filter(!is.na(nest_lon) & !is.na(nest_lat)) %>%
st_as_sf(coords = c("nest_lon", "nest_lat"),
crs = 4326) %>%
mapview(popup = popupTable(.,
zcol = c("season",
"site",
"nest_ID")))ggplot(nest_data_FP_check, aes(first_found2_trans, fill = as.factor(Fate))) +
geom_histogram(bins = 30,
alpha = 0.8, color = "white", linewidth = 0.2) +
scale_fill_manual(values = c("1" = brewer.pal(8, "Set1")[c(1)], "0" = brewer.pal(8, "Set1")[c(2)]),
name = "Nest Fate",
labels = c("Hatched", "Failed")) +
ylab("weekly number of nests") +
scale_x_date(date_labels = "%B",
expand = c(0.01, 0.01),
date_breaks = "1 months", limits = c(min(nest_data_FP_check$first_found2_trans, na.rm = TRUE),
max(nest_data_FP_check$last_checked2_trans, na.rm = TRUE))) +
facet_wrap("season_label") +
scale_y_continuous(limits = c(0, 10), breaks = c(2, 4, 6, 8, 10, 12)) +
luke_theme +
xlab("Found date") +
theme(legend.position = "top",
panel.grid.major = element_line(colour = "grey70",
size = 0.15),
axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5))ggplot(nest_data_FP_check, aes(last_alive2_trans, fill = as.factor(Fate))) +
geom_histogram(bins = 30,
alpha = 0.8, color = "white", linewidth = 0.2) +
scale_fill_manual(values = c("1" = brewer.pal(8, "Set1")[c(1)], "0" = brewer.pal(8, "Set1")[c(2)]),
name = "Nest Fate",
labels = c("Hatched", "Failed")) +
ylab("weekly number of nests") +
scale_x_date(date_labels = "%B",
expand = c(0.01, 0.01),
date_breaks = "1 months", limits = c(min(nest_data_FP_check$first_found2_trans, na.rm = TRUE),
max(nest_data_FP_check$last_checked2_trans, na.rm = TRUE))) +
facet_wrap("season_label") +
scale_y_continuous(limits = c(0, 10), breaks = c(2, 4, 6, 8, 10, 12)) +
luke_theme +
xlab("Last alive date") +
theme(legend.position = "top",
panel.grid.major = element_line(colour = "grey70",
size = 0.15),
axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5))ggplot(nest_data_FP_check, aes(last_checked2_trans, fill = as.factor(Fate))) +
geom_histogram(bins = 30,
alpha = 0.8, color = "white", linewidth = 0.2) +
scale_fill_manual(values = c("1" = brewer.pal(8, "Set1")[c(1)], "0" = brewer.pal(8, "Set1")[c(2)]),
name = "Nest Fate",
labels = c("Hatched", "Failed")) +
ylab("weekly number of nests") +
scale_x_date(date_labels = "%B",
expand = c(0.01, 0.01),
date_breaks = "1 months", limits = c(min(nest_data_FP_check$first_found2_trans, na.rm = TRUE),
max(nest_data_FP_check$last_checked2_trans, na.rm = TRUE))) +
facet_wrap("season_label") +
scale_y_continuous(limits = c(0, 10), breaks = c(2, 4, 6, 8, 10, 12)) +
luke_theme +
xlab("Last checked date") +
theme(legend.position = "top",
panel.grid.major = element_line(colour = "grey70",
size = 0.15),
axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5))# assess if there are nests with unusually long incubation periods
nest_data_FP_check %>%
mutate(found_and_alive_diff = last_alive2 - first_found2) %>%
filter(FirstFound < LastPresent & FirstFound < LastChecked) %>%
ggplot() +
geom_histogram(aes(found_and_alive_diff)) +
luke_theme +
xlab("Time between found date and last alive date (days)") +
ylab("Frquency of nests")# A tibble: 0 × 26
# Groups: season [0]
# ℹ 26 variables: season <fct>, site <fct>, nest_ID <chr>, first_found <chr>,
# last_alive <chr>, last_checked <chr>, Fate <chr>, nest_hab <fct>,
# management_status <fct>, management_type <chr>, nest_lat <chr>,
# nest_lon <chr>, first_found2 <date>, last_alive2 <date>,
# last_checked2 <date>, FirstFound <dbl>, LastPresent <dbl>,
# LastChecked <dbl>, sign_access <dbl>, sign_nest <dbl>, rope_fence <dbl>,
# wardens <dbl>, none <dbl>, management_level <dbl>, nocc <dbl>, …
# A tibble: 0 × 26
# Groups: season [0]
# ℹ 26 variables: season <fct>, site <fct>, nest_ID <chr>, first_found <chr>,
# last_alive <chr>, last_checked <chr>, Fate <chr>, nest_hab <fct>,
# management_status <fct>, management_type <chr>, nest_lat <chr>,
# nest_lon <chr>, first_found2 <date>, last_alive2 <date>,
# last_checked2 <date>, FirstFound <dbl>, LastPresent <dbl>,
# LastChecked <dbl>, sign_access <dbl>, sign_nest <dbl>, rope_fence <dbl>,
# wardens <dbl>, none <dbl>, management_level <dbl>, nocc <dbl>, …
# A tibble: 0 × 26
# Groups: season [0]
# ℹ 26 variables: season <fct>, site <fct>, nest_ID <chr>, first_found <chr>,
# last_alive <chr>, last_checked <chr>, Fate <chr>, nest_hab <fct>,
# management_status <fct>, management_type <chr>, nest_lat <chr>,
# nest_lon <chr>, first_found2 <date>, last_alive2 <date>,
# last_checked2 <date>, FirstFound <dbl>, LastPresent <dbl>,
# LastChecked <dbl>, sign_access <dbl>, sign_nest <dbl>, rope_fence <dbl>,
# wardens <dbl>, none <dbl>, management_level <dbl>, nocc <dbl>, …
As above, first we import the data and run a few checks to assess if there are any rows with the issues listed above
suppressMessages(bind_rows(
read_excel(paste0("data/final/final_final/final_final_final/", "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("BellSurfCoast", " ", "2020", "_", str_sub("2021", 3, 4)),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("BellSurfCoast", " ", "2019", "_", str_sub("2020", 3, 4)),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("BellSurfCoast", " ", "2018", "_", str_sub("2019", 3, 4)),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("BellSurfCoast", " ", "2017", "_", str_sub("2018", 3, 4)),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("BellSurfCoast", " ", "2016", "_", str_sub("2017", 3, 4)),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("BellSurfCoast", " ", "2015", "_", str_sub("2016", 3, 4)),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("BellSurfCoast", " ", "2014", "_", str_sub("2015", 3, 4)),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("BellSurfCoast", " ", "2013", "_", str_sub("2014", 3, 4)),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("BellSurfCoast", " ", "2012", "_", str_sub("2013", 3, 4)),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("BellSurfCoast", " ", "2011", "_", str_sub("2012", 3, 4)),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("BellSurfCoast", " ", "2010", "_", str_sub("2011", 3, 4)),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("BellSurfCoast", " ", "2009", "_", str_sub("2010", 3, 4)),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("BellSurfCoast", " ", "2008", "_", str_sub("2009", 3, 4)),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("BellSurfCoast", " ", "2007", "_", str_sub("2008", 3, 4)),
col_types = "text", na = "n/a"),
read_excel(paste0("data/final/final_final/final_final_final/", "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx"),
sheet = paste0("BellSurfCoast", " ", "2006", "_", str_sub("2007", 3, 4)),
col_types = "text", na = "n/a"))) %>%
rename(first_found = 10,
last_alive = 29,
last_checked = 36,
Fate = `Hatch?`,
season = Season,
site = Site,
nest_ID = `Nest ID`,
nest_hab = `Nest habitat`,
management_status = `Nest managed?`,
management_type = `Management type`,
nest_lat = `Nest latitude`,
nest_lon = `Nest longitude`) %>%
dplyr::select(season, site, nest_ID, first_found, last_alive, last_checked, Fate, nest_hab,
management_status, management_type, nest_lat, nest_lon, site) %>%
mutate(Fate = ifelse(Fate == "?", "Unk", Fate)) %>%
mutate(Fate = toupper(Fate)) %>%
mutate(last_alive = ifelse(str_detect(last_alive, "Unk."), NA, last_alive),
Fate = ifelse(Fate == "Y", 0,
ifelse(Fate == "N", 1,
ifelse(Fate == "UNK", NA, "XXX")))) %>%
mutate(
last_checked = ifelse(!is.na(last_alive) & is.na(last_checked),
last_alive,
ifelse(is.na(last_alive) & is.na(last_checked),
first_found,
last_checked))) %>%
mutate(
last_alive = ifelse(is.na(last_alive) & Fate == "0" & !is.na(last_checked),
last_checked,
ifelse(is.na(last_alive) & Fate == "1" & !is.na(last_checked),
first_found,
last_alive))) %>%
mutate(first_found2 = as.Date(paste(str_sub(first_found, 5, 8),
str_sub(first_found, 3, 4),
str_sub(first_found, 1, 2), sep = "-")),
last_alive2 = as.Date(paste(str_sub(last_alive, 5, 8),
str_sub(last_alive, 3, 4),
str_sub(last_alive, 1, 2), sep = "-")),
last_checked2 = as.Date(paste(str_sub(last_checked, 5, 8),
str_sub(last_checked, 3, 4),
str_sub(last_checked, 1, 2), sep = "-"))) %>%
mutate(FirstFound = as.numeric(format(first_found2 + 180, "%j")),
LastPresent = as.numeric(format(last_alive2 + 180, "%j")),
LastChecked = as.numeric(format(last_checked2 + 180, "%j"))) %>%
mutate(management_type = tolower(management_type)) %>%
mutate(management_type = str_replace(management_type, "acess", "access")) %>%
mutate(management_type = str_replace(management_type, "and", ",")) %>%
mutate(management_type = str_replace(management_type, "temporary", "")) %>%
mutate(management_type = str_replace_all(management_type, " ", "")) %>%
mutate(management_type = str_replace_all(management_type, "shelters", "")) %>%
mutate(management_type = str_replace_all(management_type, "banners", "")) %>%
mutate(management_type = str_replace_all(management_type, ",,", ",")) %>%
mutate(sign_access = ifelse(str_detect(management_type, "signaccess"), 1, 0)) %>%
mutate(sign_nest = ifelse(str_detect(management_type, "signnest"), 1, 0)) %>%
mutate(rope_fence = ifelse(str_detect(management_type, "ropefence"), 1, 0)) %>%
mutate(wardens = ifelse(str_detect(management_type, "wardens"), 1, 0)) %>%
mutate(none = ifelse(str_detect(management_type, "none"), 1, 0)) %>%
mutate(other = ifelse(str_detect(management_type, "other"), 1, 0)) %>%
mutate(management_level = ifelse(sign_access == 1 & sign_nest == 1 & rope_fence == 1 & wardens == 1, 4,
ifelse(rope_fence == 1, 3,
ifelse(sign_nest == 1, 2,
ifelse(sign_access == 1, 1,
ifelse(none == 1, 0, NA)))))) %>%
mutate(sign_nest_no_sign_access = ifelse(sign_access == 0 & sign_nest == 1, 1, 0)) %>%
mutate(fence_no_sign = ifelse((sign_access == 0 & sign_nest == 0) & rope_fence == 1, 1, 0)) %>%
mutate(wardens_no_sign = ifelse((sign_access == 0 & sign_nest == 0) & wardens == 1, 1, 0)) %>%
mutate(wardens_no_fence = ifelse(rope_fence == 1 & wardens == 1, 1, 0)) %>%
mutate(just_wardens = ifelse(rope_fence == 0 & sign_access == 0 & sign_nest == 0 & wardens == 1, 1, 0)) %>%
dplyr::select(-other, -sign_nest_no_sign_access, -fence_no_sign,
-wardens_no_sign, -wardens_no_fence, -just_wardens) %>%
group_by(season) %>%
mutate(nocc = max(max(LastChecked, na.rm = TRUE), max(LastPresent, na.rm = TRUE)),
season = as.factor(season),
nest_hab = as.factor(nest_hab),
management_status = as.factor(management_status)) %>%
mutate(region = "BellSurfCoast") %>%
mutate(site = as.factor(site)) %>%
mutate(issue1 = ifelse(nchar(first_found) != 8, "found date is not 8 characters; ", NA)) %>%
mutate(issue2 = ifelse(nchar(last_alive) != 8, "last seen alive date is not 8 characters; ", NA)) %>%
mutate(issue3 = ifelse(nchar(last_checked) != 8, "last checked date is not 8 characters; ", NA)) %>%
mutate(issue4 = ifelse(is.na(first_found), "found date missing; ", NA)) %>%
mutate(issue5 = ifelse(is.na(last_alive), "last seen alive date missing; ", NA)) %>%
mutate(issue6 = ifelse(is.na(last_checked), "last checked date missing; ", NA)) %>%
mutate(issue7 = ifelse(management_status %!in% c("Y", "N"), "Nest managed? is not Y or N; ", NA)) %>%
mutate(issue8 = ifelse(nest_hab %!in% c("Beach", "Dune", "Foredune/face", "Estuary/spit", "Rocks"), "Nest habitat is not Beach, Dune, Foredune/face, Estuary/spit, or Rocks; ", NA)) %>%
mutate(issue9 = ifelse(is.na(management_level), "Management type is not sufficient for making levels; ", NA)) %>%
mutate(found_and_alive_diff = last_alive2 - first_found2) %>%
mutate(issue10 = ifelse(found_and_alive_diff > 35 , "Double check dates because incubation time greater than 35 days; ", NA)) %>%
mutate(issue11 = ifelse(FirstFound > LastPresent, "Found date is after Last Alive date (should be greater or equal); ", NA)) %>%
mutate(issue12 = ifelse(FirstFound > LastChecked, "Found date is after Last Checked date (should be greater or equal); ", NA)) %>%
mutate(issue13 = ifelse(LastChecked < LastPresent, "Last Checked date is before Last Alive date (should be greater or equal); ", NA)) %>%
mutate(issues = ifelse(is.na(issue1) & is.na(issue2) & is.na(issue3) &
is.na(issue4) & is.na(issue5) & is.na(issue6) &
is.na(issue7) & is.na(issue8) & is.na(issue9) &
is.na(issue10) & is.na(issue11) & is.na(issue12) & is.na(issue13), NA,
paste0(issue1, issue2, issue3,
issue4, issue5, issue6,
issue7, issue8, issue9,
issue10, issue11, issue12, issue13))) %>%
mutate(issues = str_remove_all(issues, "NA")) %>%
mutate(issues = ifelse(is.na(issues), "usable", issues)) %>%
dplyr::select(-issue1, -issue2, -issue3,
-issue4, -issue5, -issue6,
-issue7, -issue8, -issue9,
-issue10, -issue11, -issue12, -issue13) %>%
filter(issues != "usable") %>%
arrange(issues) %>%
filter(first_found != "Not found" & last_alive != "Not seen" & last_checked != "Not seen" & last_checked != "Not revisited" & last_checked != "Not revisted") %>%
filter(str_detect(issues, "date")) %>%
mutate(issues = str_remove_all(issues, "Management type is not sufficient for making levels; ")) %>%
mutate(issues = str_remove_all(issues, "Nest habitat is not Beach, Dune, Foredune/face, Estuary/spit, or Rocks; ")) %>%
dplyr::select(season, nest_ID, first_found, first_found2, last_alive, last_alive2, last_checked, last_checked2, Fate, found_and_alive_diff, issues) %>%
datatable(class = 'cell-border stripe', rownames = FALSE, filter = 'top')#%>% # write_csv(., "data/final/final_final/final_final_final/nest_issues_commented/Bellarine_Surf Coast Nesting with site names matching with threat data doc_nests_w_issues_commented.csv", col_names = TRUE, append = FALSE, quote = "all")nest_data_BSC <-
bind_rows(
lucinda_nest_import(year_1 = "2020", year_2 = "2021",
first_found_date_col = 10, last_alive_date_col = 29, last_checked_col = 36,
file_name = "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx", site = "BellSurfCoast"),
lucinda_nest_import(year_1 = "2019", year_2 = "2020",
first_found_date_col = 10, last_alive_date_col = 29, last_checked_col = 36,
file_name = "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx", site = "BellSurfCoast"),
lucinda_nest_import(year_1 = "2018", year_2 = "2019",
first_found_date_col = 10, last_alive_date_col = 29, last_checked_col = 36,
file_name = "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx", site = "BellSurfCoast"),
lucinda_nest_import(year_1 = "2017", year_2 = "2018",
first_found_date_col = 10, last_alive_date_col = 29, last_checked_col = 36,
file_name = "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx", site = "BellSurfCoast"),
lucinda_nest_import(year_1 = "2016", year_2 = "2017",
first_found_date_col = 10, last_alive_date_col = 29, last_checked_col = 36,
file_name = "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx", site = "BellSurfCoast"),
lucinda_nest_import(year_1 = "2015", year_2 = "2016",
first_found_date_col = 10, last_alive_date_col = 29, last_checked_col = 36,
file_name = "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx", site = "BellSurfCoast"),
lucinda_nest_import(year_1 = "2014", year_2 = "2015",
first_found_date_col = 10, last_alive_date_col = 29, last_checked_col = 36,
file_name = "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx", site = "BellSurfCoast"),
lucinda_nest_import(year_1 = "2013", year_2 = "2014",
first_found_date_col = 10, last_alive_date_col = 29, last_checked_col = 36,
file_name = "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx", site = "BellSurfCoast"),
lucinda_nest_import(year_1 = "2012", year_2 = "2013",
first_found_date_col = 10, last_alive_date_col = 29, last_checked_col = 36,
file_name = "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx", site = "BellSurfCoast"),
lucinda_nest_import(year_1 = "2011", year_2 = "2012",
first_found_date_col = 10, last_alive_date_col = 29, last_checked_col = 36,
file_name = "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx", site = "BellSurfCoast"),
lucinda_nest_import(year_1 = "2010", year_2 = "2011",
first_found_date_col = 10, last_alive_date_col = 29, last_checked_col = 36,
file_name = "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx", site = "BellSurfCoast"),
lucinda_nest_import(year_1 = "2009", year_2 = "2010",
first_found_date_col = 10, last_alive_date_col = 29, last_checked_col = 36,
file_name = "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx", site = "BellSurfCoast"),
lucinda_nest_import(year_1 = "2008", year_2 = "2009",
first_found_date_col = 10, last_alive_date_col = 29, last_checked_col = 36,
file_name = "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx", site = "BellSurfCoast"),
lucinda_nest_import(year_1 = "2007", year_2 = "2008",
first_found_date_col = 10, last_alive_date_col = 29, last_checked_col = 36,
file_name = "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx", site = "BellSurfCoast"),
lucinda_nest_import(year_1 = "2006", year_2 = "2007",
first_found_date_col = 10, last_alive_date_col = 29, last_checked_col = 36,
file_name = "Bellarine_Surf Coast Nesting 2006_2021 fix ups post email from Luke 27_2_24.xlsx", site = "BellSurfCoast"),
) %>%
group_by(season) %>%
mutate(nocc = max(max(LastChecked, na.rm = TRUE), max(LastPresent, na.rm = TRUE)),
season = as.factor(season),
nest_hab = as.factor(nest_hab),
management_status = as.factor(management_status)) %>%
filter(!is.na(FirstFound) & !is.na(LastPresent) & !is.na(LastChecked)) %>%
filter(management_status %in% c("Y", "N")) %>%
filter(nest_hab %in% c("Beach", "Dune", "Foredune/face")) %>%
filter(!is.na(management_level)) %>%
mutate(region = "BSC") %>%
mutate(site = as.factor(site))nest_data_BSC_check <-
nest_data_BSC %>%
ungroup() %>%
mutate(first_found2_md = paste(format(first_found2 + 180, format = "%m"),
format(first_found2 + 180, format = "%d"),
sep = "-"),
last_alive2_md = paste(format(last_alive2 + 180, format = "%m"),
format(last_alive2 + 180, format = "%d"),
sep = "-"),
last_checked2_md = paste(format(last_checked2 + 180, format = "%m"),
format(last_checked2 + 180, format = "%d"),
sep = "-")) %>%
mutate(first_found2_trans = as.Date(paste("2020", first_found2_md, sep = "-"), format = "%Y-%m-%d") - 179,
last_alive2_trans = as.Date(paste("2020", last_alive2_md, sep = "-"), format = "%Y-%m-%d") - 179,
last_checked2_trans = as.Date(paste("2020", last_checked2_md, sep = "-"), format = "%Y-%m-%d") - 179) %>%
mutate(season_label = paste0("season ", str_sub(season, 1, 4), " to ", str_sub(season, 5, 6)))Note that this map only shows data that are in a decimal degrees format (e.g., -38.31), NOT degree minute seconds (e.g., 38 27.59). The map is interactive, so click on an outlier to see its metadata
nest_data_BSC %>%
mutate(nest_lon = as.numeric(nest_lon),
nest_lat = as.numeric(nest_lat)) %>%
filter(!is.na(nest_lon) & !is.na(nest_lat)) %>%
st_as_sf(coords = c("nest_lon", "nest_lat"),
crs = 4326) %>%
mapview(popup = popupTable(.,
zcol = c("season",
"site",
"nest_ID")))ggplot(nest_data_BSC_check, aes(first_found2_trans, fill = as.factor(Fate))) +
geom_histogram(bins = 30,
alpha = 0.8, color = "white", linewidth = 0.2) +
scale_fill_manual(values = c("1" = brewer.pal(8, "Set1")[c(1)], "0" = brewer.pal(8, "Set1")[c(2)]),
name = "Nest Fate",
labels = c("Hatched", "Failed")) +
ylab("weekly number of nests") +
scale_x_date(date_labels = "%B",
expand = c(0.01, 0.01),
date_breaks = "1 months", limits = c(min(nest_data_BSC_check$first_found2_trans, na.rm = TRUE),
max(nest_data_BSC_check$last_checked2_trans, na.rm = TRUE))) +
facet_wrap("season_label") +
# scale_y_continuous(limits = c(0, 10), breaks = c(2, 4, 6, 8, 10, 12)) +
luke_theme +
xlab("Found date") +
theme(legend.position = "top",
panel.grid.major = element_line(colour = "grey70",
size = 0.15),
axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5))ggplot(nest_data_BSC_check, aes(last_alive2_trans, fill = as.factor(Fate))) +
geom_histogram(bins = 30,
alpha = 0.8, color = "white", linewidth = 0.2) +
scale_fill_manual(values = c("1" = brewer.pal(8, "Set1")[c(1)], "0" = brewer.pal(8, "Set1")[c(2)]),
name = "Nest Fate",
labels = c("Hatched", "Failed")) +
ylab("weekly number of nests") +
scale_x_date(date_labels = "%B",
expand = c(0.01, 0.01),
date_breaks = "1 months", limits = c(min(nest_data_BSC_check$first_found2_trans, na.rm = TRUE),
max(nest_data_BSC_check$last_checked2_trans, na.rm = TRUE))) +
facet_wrap("season_label") +
# scale_y_continuous(limits = c(0, 10), breaks = c(2, 4, 6, 8, 10, 12)) +
luke_theme +
xlab("Last alive date") +
theme(legend.position = "top",
panel.grid.major = element_line(colour = "grey70",
size = 0.15),
axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5))ggplot(nest_data_BSC_check, aes(last_checked2_trans, fill = as.factor(Fate))) +
geom_histogram(bins = 30,
alpha = 0.8, color = "white", linewidth = 0.2) +
scale_fill_manual(values = c("1" = brewer.pal(8, "Set1")[c(1)], "0" = brewer.pal(8, "Set1")[c(2)]),
name = "Nest Fate",
labels = c("Hatched", "Failed")) +
ylab("weekly number of nests") +
scale_x_date(date_labels = "%B",
expand = c(0.01, 0.01),
date_breaks = "1 months", limits = c(min(nest_data_BSC_check$first_found2_trans, na.rm = TRUE),
max(nest_data_BSC_check$last_checked2_trans, na.rm = TRUE))) +
facet_wrap("season_label") +
# scale_y_continuous(limits = c(0, 10), breaks = c(2, 4, 6, 8, 10, 12)) +
luke_theme +
xlab("Last checked date") +
theme(legend.position = "top",
panel.grid.major = element_line(colour = "grey70",
size = 0.15),
axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5))# assess if there are nests with unusually long incubation periods
nest_data_BSC_check %>%
mutate(found_and_alive_diff = last_alive2 - first_found2) %>%
filter(FirstFound < LastPresent & FirstFound < LastChecked) %>%
ggplot() +
geom_histogram(aes(found_and_alive_diff)) +
luke_theme +
xlab("Time between found date and last alive date (days)") +
ylab("Frquency of nests")# A tibble: 0 × 26
# Groups: season [0]
# ℹ 26 variables: season <fct>, site <fct>, nest_ID <chr>, first_found <chr>,
# last_alive <chr>, last_checked <chr>, Fate <chr>, nest_hab <fct>,
# management_status <fct>, management_type <chr>, nest_lat <chr>,
# nest_lon <chr>, first_found2 <date>, last_alive2 <date>,
# last_checked2 <date>, FirstFound <dbl>, LastPresent <dbl>,
# LastChecked <dbl>, sign_access <dbl>, sign_nest <dbl>, rope_fence <dbl>,
# wardens <dbl>, none <dbl>, management_level <dbl>, nocc <dbl>, …
# A tibble: 0 × 26
# Groups: season [0]
# ℹ 26 variables: season <fct>, site <fct>, nest_ID <chr>, first_found <chr>,
# last_alive <chr>, last_checked <chr>, Fate <chr>, nest_hab <fct>,
# management_status <fct>, management_type <chr>, nest_lat <chr>,
# nest_lon <chr>, first_found2 <date>, last_alive2 <date>,
# last_checked2 <date>, FirstFound <dbl>, LastPresent <dbl>,
# LastChecked <dbl>, sign_access <dbl>, sign_nest <dbl>, rope_fence <dbl>,
# wardens <dbl>, none <dbl>, management_level <dbl>, nocc <dbl>, …
# A tibble: 0 × 26
# Groups: season [0]
# ℹ 26 variables: season <fct>, site <fct>, nest_ID <chr>, first_found <chr>,
# last_alive <chr>, last_checked <chr>, Fate <chr>, nest_hab <fct>,
# management_status <fct>, management_type <chr>, nest_lat <chr>,
# nest_lon <chr>, first_found2 <date>, last_alive2 <date>,
# last_checked2 <date>, FirstFound <dbl>, LastPresent <dbl>,
# LastChecked <dbl>, sign_access <dbl>, sign_nest <dbl>, rope_fence <dbl>,
# wardens <dbl>, none <dbl>, management_level <dbl>, nocc <dbl>, …
# FP_threat_data <-
# read_excel("data/final/final_final/Merged threat data_FP_MP.xlsx",
# sheet = "FP Threat DATA",
# col_types = "text") %>%
# mutate(season = str_remove(Season, "/")) %>%
# filter(Region %in% c("Fleurieu Peninsula")) %>%
# rename(obs_lon = `Observation Longitude`,
# obs_lat = `Observation Latitude`,
# obs_date = `Observation Date`) %>%
# mutate(obs_date = as.Date(as.numeric(obs_date),
# origin = "1899-12-30")) %>%
# mutate(obs_date2 = as.numeric(format(obs_date + 180, "%j"))) %>%
# mutate(region = "FP")
#
# MP_threat_data <-
# read_excel("data/final/final_final/Merged threat data_FP_MP.xlsx",
# sheet = "MP Threat DATA",
# col_types = "text") %>%
# mutate(season = str_remove(Season, "/")) %>%
# filter(Region %in% c("Mornington Peninsula")) %>%
# rename(obs_lon = `Observation Longitude`,
# obs_lat = `Observation Latitude`,
# obs_date = `Observation Date`) %>%
# mutate(obs_date = as.Date(as.numeric(obs_date),
# origin = "1899-12-30")) %>%
# mutate(obs_date2 = as.numeric(format(obs_date + 180, "%j"))) %>%
# mutate(region = "MP")
#
# BSC_threat_data <-
# read_excel("data/final/final_final/Merged threat data_BSC.xlsx",
# sheet = "BellSurf Threat DATA",
# col_types = "text") %>%
# mutate(season = str_remove(Season, "/")) %>%
# rename(obs_lon = `Observation Longitude`,
# obs_lat = `Observation Latitude`,
# obs_date = `Observation date`) %>%
# mutate(obs_date = as.Date(as.numeric(obs_date),
# origin = "1899-12-30")) %>%
# mutate(obs_date2 = as.numeric(format(obs_date + 180, "%j"))) %>%
# mutate(region = "BSC")
FP_threat_data <-
read_excel("data/final/final_final/final_final_final/Merged threat data.xlsx",
sheet = "FP Threat DATA",
col_types = "text") %>%
mutate(season = str_remove(Season, "/")) %>%
rename(obs_lon = `Observation Longitude`,
obs_lat = `Observation Latitude`,
obs_date = `Observation Date`) %>%
mutate(obs_date = as.Date(as.numeric(obs_date),
origin = "1899-12-30")) %>%
mutate(obs_date2 = as.numeric(format(obs_date + 180, "%j"))) %>%
mutate(region = "FP")
MP_threat_data <-
read_excel("data/final/final_final/final_final_final/Merged threat data.xlsx",
sheet = "MP Threat DATA",
col_types = "text") %>%
mutate(season = str_remove(Season, "/")) %>%
rename(obs_lon = `Observation Longitude`,
obs_lat = `Observation Latitude`,
obs_date = `Observation Date`) %>%
mutate(obs_date = as.Date(as.numeric(obs_date),
origin = "1899-12-30")) %>%
mutate(obs_date2 = as.numeric(format(obs_date + 180, "%j"))) %>%
mutate(region = "MP")
BSC_threat_data <-
read_excel("data/final/final_final/final_final_final/Merged threat data.xlsx",
sheet = "BellSurf Threat DATA",
col_types = "text") %>%
mutate(season = str_remove(Season, "/")) %>%
rename(obs_lon = `Observation Longitude`,
obs_lat = `Observation Latitude`,
obs_date = `Observation date`) %>%
mutate(obs_date = as.Date(as.numeric(obs_date),
origin = "1899-12-30")) %>%
mutate(obs_date2 = as.numeric(format(obs_date + 180, "%j"))) %>%
mutate(region = "BSC")
threat_data <-
bind_rows(FP_threat_data, MP_threat_data, BSC_threat_data)threat_data_ <-
threat_data %>%
rename(site = `Site name`) %>%
# first convert all the count columns to numeric
mutate_at(vars(
`Walkers/Joggers (wet sand)`,`Walkers/Joggers (dry sand)`,
`Walkers/Joggers (signs/fence)`,`Walkers/Joggers (Dune)`,`People sunbaking/sitting (wet sand)`,
`People sunbaking/sitting (dry sand)`,`People sunbaking/sitting (signs/fence)`,
`People sunbaking/sitting (Dune)`,`Surfers/Swimmers (wet sand)`,
`Surfers/Swimmers (dry sand)`,`Surfers/Swimmers (signs/fence)`,
`Surfers/Swimmers (Dune)`,`People Fishing (wet sand)`,
`People Fishing (dry sand)`,`People Fishing (signs/fence)`,
`People Fishing (Dune)`,`People Playing Games (wet sand)`,
`People Playing Games (dry sand)`,`People Playing Games (signs/fence)`,
`People Playing Games (Dune)`,`Dog Walkers (wet sand)`,
`Dog Walkers (dry sand)`,`Dog Walkers (signs/fence)`,
`Dog Walkers (Dune)`,`Dog On Leash (# dogs) (wet sand)`,
`Dog On Leash (# dogs) (dry sand)`,`Dog On Leash (# dogs) (signs/fence)`,
`Dog On Leash (# dogs) (Dune)`,`Dog Off Leash (# dogs) (wet sand)`,
`Dog Off Leash (# dogs) (dry sand)`,`Dog Off Leash (# dogs) (signs/fence)`,
`Dog Off Leash (# dogs) (Dune)`,`Horses (wet sand)`,
`Horses (dry sand)`,`Horses (signs/fence)`,
`Horses (Dune)`,`Permitted vehicle (wet sand)`,
`Permitted vehicle (dry sand)`,`Permitted vehicle (signs/fence)`,
`Permitted vehicle (Dune)`,`Illegal vehicle (wet sand)`,
`Illegal vehicle (dry sand)`,`Illegal vehicle (signs/fence)`,
`Illegal vehicle (Dune)`,`Ravens (wet sand)`,
`Ravens (dry sand)`,`Ravens (signs/fence)`,
`Ravens (Dune)`,`Magpies (wet sand)`,
`Magpies (dry sand)`,`Magpies (signs/fence)`,
`Magpies (Dune)`,`Silver Gulls (wet sand)`,
`Silver Gulls (dry sand)`,`Silver Gulls (signs/fence)`,
`Silver Gulls (Dune)`,`Pacific/Kelp Gulls (wet sand)`,
`Pacific/Kelp Gulls (dry sand)`,`Pacific/Kelp Gulls (signs/fence)`,
`Pacific/Kelp Gulls (Dune)`,`Nankeen Kestrels (wet sand)`,
`Nankeen Kestrels (dry sand)`,`Nankeen Kestrels (signs/fence)`,
`Nankeen Kestrels (Dune)`,`Other bird of prey (wet sand)`,
`Other bird of prey (dry sand)`,`Other bird of prey (signs/fence)`,
`Other bird of prey (Dune)`,
`Stock (cattle/sheep) (wet sand)`,
`Stock (cattle/sheep) (dry sand)`,`Stock (cattle/sheep) (signs/fence)`,
`Stock (cattle/sheep) (Dune)`), as.numeric) %>%
ungroup() %>%
# take the total sum of counts for each threat type (e.g., humans includes
# Dog Walkers, People Playing Games, People Fishing, Surfers/Swimmers,
# People sunbaking/sitting, and Walkers/Joggers)
mutate(humans = rowSums(dplyr::select(.,`Walkers/Joggers (wet sand)`,
`Walkers/Joggers (dry sand)`,
`Walkers/Joggers (signs/fence)`,
`Walkers/Joggers (Dune)`,
`People sunbaking/sitting (wet sand)`,
`People sunbaking/sitting (dry sand)`,
`People sunbaking/sitting (signs/fence)`,
`People sunbaking/sitting (Dune)`,
`Surfers/Swimmers (wet sand)`,
`Surfers/Swimmers (dry sand)`,
`Surfers/Swimmers (signs/fence)`,
`Surfers/Swimmers (Dune)`,
`People Fishing (wet sand)`,
`People Fishing (dry sand)`,
`People Fishing (signs/fence)`,
`People Fishing (Dune)`,
`People Playing Games (wet sand)`,
`People Playing Games (dry sand)`,
`People Playing Games (signs/fence)`,
`People Playing Games (Dune)`,
`Dog Walkers (wet sand)`,
`Dog Walkers (dry sand)`,
`Dog Walkers (signs/fence)`,
`Dog Walkers (Dune)`), na.rm = TRUE),
# do a micro-habitat specific sum for humans
humans_wet = rowSums(dplyr::select(.,`Walkers/Joggers (wet sand)`,
`People sunbaking/sitting (wet sand)`,
`Surfers/Swimmers (wet sand)`,
`People Fishing (wet sand)`,
`People Playing Games (wet sand)`,
`Dog Walkers (wet sand)`), na.rm = TRUE),
humans_dry = rowSums(dplyr::select(.,`Walkers/Joggers (dry sand)`,
`People sunbaking/sitting (dry sand)`,
`Surfers/Swimmers (dry sand)`,
`People Fishing (dry sand)`,
`People Playing Games (dry sand)`,
`Dog Walkers (dry sand)`), na.rm = TRUE),
humans_dune = rowSums(dplyr::select(.,`Walkers/Joggers (Dune)`,
`People sunbaking/sitting (Dune)`,
`Surfers/Swimmers (Dune)`,
`People Fishing (Dune)`,
`People Playing Games (Dune)`,
`Dog Walkers (Dune)`), na.rm = TRUE),
humans_SF = rowSums(dplyr::select(.,`Walkers/Joggers (signs/fence)`,
`People sunbaking/sitting (signs/fence)`,
`Surfers/Swimmers (signs/fence)`,
`People Fishing (signs/fence)`,
`People Playing Games (signs/fence)`,
`Dog Walkers (signs/fence)`), na.rm = TRUE),
dogs = rowSums(dplyr::select(., `Dog On Leash (# dogs) (wet sand)`,
`Dog On Leash (# dogs) (dry sand)`,
`Dog On Leash (# dogs) (signs/fence)`,
`Dog On Leash (# dogs) (Dune)`,
`Dog Off Leash (# dogs) (wet sand)`,
`Dog Off Leash (# dogs) (dry sand)`,
`Dog Off Leash (# dogs) (signs/fence)`,
`Dog Off Leash (# dogs) (Dune)`), na.rm = TRUE),
# specify a dog on leash and a dog of leash summary
dogs_on = rowSums(dplyr::select(., `Dog On Leash (# dogs) (wet sand)`,
`Dog On Leash (# dogs) (dry sand)`,
`Dog On Leash (# dogs) (signs/fence)`,
`Dog On Leash (# dogs) (Dune)`), na.rm = TRUE),
dogs_off = rowSums(dplyr::select(., `Dog Off Leash (# dogs) (wet sand)`,
`Dog Off Leash (# dogs) (dry sand)`,
`Dog Off Leash (# dogs) (signs/fence)`,
`Dog Off Leash (# dogs) (Dune)`), na.rm = TRUE),
pred_birds = rowSums(dplyr::select(., `Ravens (wet sand)`,
`Ravens (dry sand)`,
`Ravens (signs/fence)`,
`Ravens (Dune)`,
`Magpies (wet sand)`,
`Magpies (dry sand)`,
`Magpies (signs/fence)`,
`Magpies (Dune)`#,
# `Silver Gulls (wet sand)`,
# `Silver Gulls (dry sand)`,
# `Silver Gulls (signs/fence)`,
# `Silver Gulls (Dune)`,
# `Pacific/Kelp Gulls (wet sand)`,
# `Pacific/Kelp Gulls (dry sand)`,
# `Pacific/Kelp Gulls (signs/fence)`,
# `Pacific/Kelp Gulls (Dune)`,
# `Nankeen Kestrels (wet sand)`,
# `Nankeen Kestrels (dry sand)`,
# `Nankeen Kestrels (signs/fence)`,
# `Nankeen Kestrels (Dune)`,
# `Other bird of prey (wet sand)`,
# `Other bird of prey (dry sand)`,
# `Other bird of prey (signs/fence)`,
# `Other bird of prey (Dune)`
), na.rm = TRUE),
gulls = rowSums(dplyr::select(., #`Ravens (wet sand)`,
# `Ravens (dry sand)`,
# `Ravens (signs/fence)`,
# `Ravens (Dune)`,
# `Magpies (wet sand)`,
# `Magpies (dry sand)`,
# `Magpies (signs/fence)`,
# `Magpies (Dune)`
`Silver Gulls (wet sand)`,
`Silver Gulls (dry sand)`,
`Silver Gulls (signs/fence)`,
`Silver Gulls (Dune)`,
`Pacific/Kelp Gulls (wet sand)`,
`Pacific/Kelp Gulls (dry sand)`,
`Pacific/Kelp Gulls (signs/fence)`,
`Pacific/Kelp Gulls (Dune)`
# `Nankeen Kestrels (wet sand)`,
# `Nankeen Kestrels (dry sand)`,
# `Nankeen Kestrels (signs/fence)`,
# `Nankeen Kestrels (Dune)`,
# `Other bird of prey (wet sand)`,
# `Other bird of prey (dry sand)`,
# `Other bird of prey (signs/fence)`,
# `Other bird of prey (Dune)`
), na.rm = TRUE),
vehicles = rowSums(dplyr::select(., `Permitted vehicle (wet sand)`,
`Permitted vehicle (dry sand)`,
`Permitted vehicle (signs/fence)`,
`Permitted vehicle (Dune)`,
`Illegal vehicle (wet sand)`,
`Illegal vehicle (dry sand)`,
`Illegal vehicle (signs/fence)`,
`Illegal vehicle (Dune)`), na.rm = TRUE),
hoofed_animals = rowSums(dplyr::select(.,`Horses (wet sand)`,
`Horses (dry sand)`,
`Horses (signs/fence)`,
`Horses (Dune)`,
`Stock (cattle/sheep) (wet sand)`,
`Stock (cattle/sheep) (dry sand)`,
`Stock (cattle/sheep) (signs/fence)`,
`Stock (cattle/sheep) (Dune)`), na.rm = TRUE)) %>%
# consolidate columns names
rename(hum_pri_wet = `Human Prints (wet sand)`,
hum_pri_dry = `Human Prints (dry sand)`,
hum_pri_dune = `Human Prints (Dune)`,
hum_pri_SF = `Human Prints (signs/fence)`,
fox_pri_wet = `Fox Prints (wet sand)`,
fox_pri_dry = `Fox Prints (dry sand)`,
fox_pri_dune = `Fox Prints (Dune)`,
fox_pri_SF = `Fox Prints (signs/fence)`,
dog_pri_wet = `Dog Prints (wet sand)`,
dog_pri_dry = `Dog Prints (dry sand)`,
dog_pri_dune = `Dog Prints (Dune)`,
dog_pri_SF = `Dog Prints (signs/fence)`,
vehicle_pri_wet = `Vehicle Tracks (wet sand)`,
vehicle_pri_dry = `Vehicle Tracks (dry sand)`,
vehicle_pri_dune = `Vehicle Tracks (Dune)`,
vehicle_pri_SF = `Vehicle Tracks (signs/fence)`,
trailbike_pri_wet = `Trail bike tracks (wet sand)`,
trailbike_pri_dry = `Trail bike tracks (dry sand)`,
trailbike_pri_dune = `Trail bike tracks (Dune)`,
trailbike_pri_SF = `Trail bike tracks (signs/fence)`,
stock_pri_wet = `Stock (wet sand)`,
stock_pri_dry = `Stock (dry sand)`,
stock_pri_dune = `Stock (Dune)`,
stock_pri_SF = `Stock (signs/fence)`,
horse_pri_wet = `Horses Prints (wet sand)`,
horse_pri_dry = `Horses Prints (dry sand)`,
horse_pri_dune = `Horses Prints (Dune)`,
horse_pri_SF = `Horses Prints (signs/fence)`) %>%
# specify coordinates as numeric
mutate(obs_lon = as.numeric(obs_lon),
obs_lat = as.numeric(obs_lat)) %>%
# clean up factor levels (e.g., sometime "Light", sometimes just "L")
mutate(hum_pri_wet = ifelse(hum_pri_wet %in% c("Light", "Moderate", "Heavy", "L", "M", "H"),
substr(hum_pri_wet, 1, 1),
ifelse(hum_pri_wet == "0", "N",
ifelse(hum_pri_wet == "1", "L",
ifelse(hum_pri_wet == "2", "M",
ifelse(hum_pri_wet == "3", "H",
ifelse(hum_pri_wet == "high", "H", NA)))))) %>% as.factor(.) %>% factor(., levels = c("L", "M", "H")),
hum_pri_dry = ifelse(hum_pri_dry %in% c("Light", "Moderate", "Heavy", "L", "M", "H"),
substr(hum_pri_dry, 1, 1),
ifelse(hum_pri_dry == "0", "N",
ifelse(hum_pri_dry == "1", "L",
ifelse(hum_pri_dry == "2", "M",
ifelse(hum_pri_dry == "3", "H",
ifelse(hum_pri_dry == "high", "H", NA)))))) %>% as.factor(.) %>% factor(., levels = c("L", "M", "H")),
hum_pri_SF = ifelse(hum_pri_SF %in% c("Light", "Moderate", "Heavy", "L", "M", "H"),
substr(hum_pri_SF, 1, 1),
ifelse(hum_pri_SF == "0", "N",
ifelse(hum_pri_SF == "1", "L",
ifelse(hum_pri_SF == "2", "M",
ifelse(hum_pri_SF == "3", "H",
ifelse(hum_pri_SF == "high", "H", NA)))))) %>% as.factor(.) %>% factor(., levels = c("L", "M", "H")),
hum_pri_dune = ifelse(hum_pri_dune %in% c("Light", "Moderate", "Heavy", "L", "M", "H"),
substr(hum_pri_dune, 1, 1),
ifelse(hum_pri_dune == "0", "N",
ifelse(hum_pri_dune == "1", "L",
ifelse(hum_pri_dune == "2", "M",
ifelse(hum_pri_dune == "3", "H",
ifelse(hum_pri_dune == "high", "H", NA)))))) %>% as.factor(.) %>% factor(., levels = c("L", "M", "H")),
fox_pri_wet = ifelse(fox_pri_wet %in% c("Light", "Moderate", "Heavy", "L", "M", "H"),
substr(fox_pri_wet, 1, 1),
ifelse(fox_pri_wet == "0", "N",
ifelse(fox_pri_wet == "1", "L",
ifelse(fox_pri_wet == "2", "M",
ifelse(fox_pri_wet == "3", "H",
ifelse(fox_pri_wet == "high", "H", NA)))))) %>% as.factor(.) %>% factor(., levels = c("L", "M", "H")),
fox_pri_dry = ifelse(fox_pri_dry %in% c("Light", "Moderate", "Heavy", "L", "M", "H"),
substr(fox_pri_dry, 1, 1),
ifelse(fox_pri_dry == "0", "N",
ifelse(fox_pri_dry == "1", "L",
ifelse(fox_pri_dry == "2", "M",
ifelse(fox_pri_dry == "3", "H",
ifelse(fox_pri_dry == "high", "H", NA)))))) %>% as.factor(.) %>% factor(., levels = c("L", "M", "H")),
fox_pri_SF = ifelse(fox_pri_SF %in% c("Light", "Moderate", "Heavy", "L", "M", "H"),
substr(fox_pri_SF, 1, 1),
ifelse(fox_pri_SF == "0", "N",
ifelse(fox_pri_SF == "1", "L",
ifelse(fox_pri_SF == "2", "M",
ifelse(fox_pri_SF == "3", "H",
ifelse(fox_pri_SF == "high", "H", NA)))))) %>% as.factor(.) %>% factor(., levels = c("L", "M", "H")),
fox_pri_dune = ifelse(fox_pri_dune %in% c("Light", "Moderate", "Heavy", "L", "M", "H"),
substr(fox_pri_dune, 1, 1),
ifelse(fox_pri_dune == "0", "N",
ifelse(fox_pri_dune == "1", "L",
ifelse(fox_pri_dune == "2", "M",
ifelse(fox_pri_dune == "3", "H",
ifelse(fox_pri_dune == "high", "H", NA)))))) %>% as.factor(.) %>% factor(., levels = c("L", "M", "H")),
dog_pri_wet = ifelse(dog_pri_wet %in% c("Light", "Moderate", "Heavy", "L", "M", "H"),
substr(dog_pri_wet, 1, 1),
ifelse(dog_pri_wet == "0", "N",
ifelse(dog_pri_wet == "1", "L",
ifelse(dog_pri_wet == "2", "M",
ifelse(dog_pri_wet == "3", "H",
ifelse(dog_pri_wet == "high", "H", NA)))))) %>% as.factor(.) %>% factor(., levels = c("L", "M", "H")),
dog_pri_dry = ifelse(dog_pri_dry %in% c("Light", "Moderate", "Heavy", "L", "M", "H"),
substr(dog_pri_dry, 1, 1),
ifelse(dog_pri_dry == "0", "N",
ifelse(dog_pri_dry == "1", "L",
ifelse(dog_pri_dry == "2", "M",
ifelse(dog_pri_dry == "3", "H",
ifelse(dog_pri_dry == "high", "H", NA)))))) %>% as.factor(.) %>% factor(., levels = c("L", "M", "H")),
dog_pri_SF = ifelse(dog_pri_SF %in% c("Light", "Moderate", "Heavy", "L", "M", "H"),
substr(dog_pri_SF, 1, 1),
ifelse(dog_pri_SF == "0", "N",
ifelse(dog_pri_SF == "1", "L",
ifelse(dog_pri_SF == "2", "M",
ifelse(dog_pri_SF == "3", "H",
ifelse(dog_pri_SF == "high", "H", NA)))))) %>% as.factor(.) %>% factor(., levels = c("L", "M", "H")),
dog_pri_dune = ifelse(dog_pri_dune %in% c("Light", "Moderate", "Heavy", "L", "M", "H"),
substr(dog_pri_dune, 1, 1),
ifelse(dog_pri_dune == "0", "N",
ifelse(dog_pri_dune == "1", "L",
ifelse(dog_pri_dune == "2", "M",
ifelse(dog_pri_dune == "3", "H",
ifelse(dog_pri_dune == "high", "H", NA)))))) %>% as.factor(.) %>% factor(., levels = c("L", "M", "H")),
vehicle_pri_wet = ifelse(vehicle_pri_wet %in% c("Light", "Moderate", "Heavy", "L", "M", "H"),
substr(vehicle_pri_wet, 1, 1),
ifelse(vehicle_pri_wet == "0", "N",
ifelse(vehicle_pri_wet == "1", "L",
ifelse(vehicle_pri_wet == "2", "M",
ifelse(vehicle_pri_wet == "3", "H",
ifelse(vehicle_pri_wet == "high", "H", NA)))))) %>% as.factor(.) %>% factor(., levels = c("L", "M", "H")),
vehicle_pri_dry = ifelse(vehicle_pri_dry %in% c("Light", "Moderate", "Heavy", "L", "M", "H"),
substr(vehicle_pri_dry, 1, 1),
ifelse(vehicle_pri_dry == "0", "N",
ifelse(vehicle_pri_dry == "1", "L",
ifelse(vehicle_pri_dry == "2", "M",
ifelse(vehicle_pri_dry == "3", "H",
ifelse(vehicle_pri_dry == "high", "H", NA)))))) %>% as.factor(.) %>% factor(., levels = c("L", "M", "H")),
vehicle_pri_SF = ifelse(vehicle_pri_SF %in% c("Light", "Moderate", "Heavy", "L", "M", "H"),
substr(vehicle_pri_SF, 1, 1),
ifelse(vehicle_pri_SF == "0", "N",
ifelse(vehicle_pri_SF == "1", "L",
ifelse(vehicle_pri_SF == "2", "M",
ifelse(vehicle_pri_SF == "3", "H",
ifelse(vehicle_pri_SF == "high", "H", NA)))))) %>% as.factor(.) %>% factor(., levels = c("L", "M", "H")),
vehicle_pri_dune = ifelse(vehicle_pri_dune %in% c("Light", "Moderate", "Heavy", "L", "M", "H"),
substr(vehicle_pri_dune, 1, 1),
ifelse(vehicle_pri_dune == "0", "N",
ifelse(vehicle_pri_dune == "1", "L",
ifelse(vehicle_pri_dune == "2", "M",
ifelse(vehicle_pri_dune == "3", "H",
ifelse(vehicle_pri_dune == "high", "H", NA)))))) %>% as.factor(.) %>% factor(., levels = c("L", "M", "H")),
trailbike_pri_wet = ifelse(trailbike_pri_wet %in% c("Light", "Moderate", "Heavy", "L", "M", "H"),
substr(trailbike_pri_wet, 1, 1),
ifelse(trailbike_pri_wet == "0", "N",
ifelse(trailbike_pri_wet == "1", "L",
ifelse(trailbike_pri_wet == "2", "M",
ifelse(trailbike_pri_wet == "3", "H",
ifelse(trailbike_pri_wet == "high", "H", NA)))))) %>% as.factor(.) %>% factor(., levels = c("L", "M", "H")),
trailbike_pri_dry = ifelse(trailbike_pri_dry %in% c("Light", "Moderate", "Heavy", "L", "M", "H"),
substr(trailbike_pri_dry, 1, 1),
ifelse(trailbike_pri_dry == "0", "N",
ifelse(trailbike_pri_dry == "1", "L",
ifelse(trailbike_pri_dry == "2", "M",
ifelse(trailbike_pri_dry == "3", "H",
ifelse(trailbike_pri_dry == "high", "H", NA)))))) %>% as.factor(.) %>% factor(., levels = c("L", "M", "H")),
trailbike_pri_SF = ifelse(trailbike_pri_SF %in% c("Light", "Moderate", "Heavy", "L", "M", "H"),
substr(trailbike_pri_SF, 1, 1),
ifelse(trailbike_pri_SF == "0", "N",
ifelse(trailbike_pri_SF == "1", "L",
ifelse(trailbike_pri_SF == "2", "M",
ifelse(trailbike_pri_SF == "3", "H",
ifelse(trailbike_pri_SF == "high", "H", NA)))))) %>% as.factor(.) %>% factor(., levels = c("L", "M", "H")),
trailbike_pri_dune = ifelse(trailbike_pri_dune %in% c("Light", "Moderate", "Heavy", "L", "M", "H"),
substr(trailbike_pri_dune, 1, 1),
ifelse(trailbike_pri_dune == "0", "N",
ifelse(trailbike_pri_dune == "1", "L",
ifelse(trailbike_pri_dune == "2", "M",
ifelse(trailbike_pri_dune == "3", "H",
ifelse(trailbike_pri_dune == "high", "H", NA)))))) %>% as.factor(.) %>% factor(., levels = c("L", "M", "H")),
horse_pri_wet = ifelse(horse_pri_wet %in% c("Light", "Moderate", "Heavy", "L", "M", "H"),
substr(horse_pri_wet, 1, 1),
ifelse(horse_pri_wet == "0", "N",
ifelse(horse_pri_wet == "1", "L",
ifelse(horse_pri_wet == "2", "M",
ifelse(horse_pri_wet == "3", "H",
ifelse(horse_pri_wet == "high", "H", NA)))))) %>% as.factor(.) %>% factor(., levels = c("L", "M", "H")),
horse_pri_dry = ifelse(horse_pri_dry %in% c("Light", "Moderate", "Heavy", "L", "M", "H"),
substr(horse_pri_dry, 1, 1),
ifelse(horse_pri_dry == "0", "N",
ifelse(horse_pri_dry == "1", "L",
ifelse(horse_pri_dry == "2", "M",
ifelse(horse_pri_dry == "3", "H",
ifelse(horse_pri_dry == "high", "H", NA)))))) %>% as.factor(.) %>% factor(., levels = c("L", "M", "H")),
horse_pri_SF = ifelse(horse_pri_SF %in% c("Light", "Moderate", "Heavy", "L", "M", "H"),
substr(horse_pri_SF, 1, 1),
ifelse(horse_pri_SF == "0", "N",
ifelse(horse_pri_SF == "1", "L",
ifelse(horse_pri_SF == "2", "M",
ifelse(horse_pri_SF == "3", "H",
ifelse(horse_pri_SF == "high", "H", NA)))))) %>% as.factor(.) %>% factor(., levels = c("L", "M", "H")),
horse_pri_dune = ifelse(horse_pri_dune %in% c("Light", "Moderate", "Heavy", "L", "M", "H"),
substr(horse_pri_dune, 1, 1),
ifelse(horse_pri_dune == "0", "N",
ifelse(horse_pri_dune == "1", "L",
ifelse(horse_pri_dune == "2", "M",
ifelse(horse_pri_dune == "3", "H",
ifelse(horse_pri_dune == "high", "H", NA)))))) %>% as.factor(.) %>% factor(., levels = c("L", "M", "H")),
stock_pri_wet = ifelse(stock_pri_wet %in% c("Light", "Moderate", "Heavy", "L", "M", "H"),
substr(stock_pri_wet, 1, 1),
ifelse(stock_pri_wet == "0", "N",
ifelse(stock_pri_wet == "1", "L",
ifelse(stock_pri_wet == "2", "M",
ifelse(stock_pri_wet == "3", "H",
ifelse(stock_pri_wet == "high", "H", NA)))))) %>% as.factor(.) %>% factor(., levels = c("L", "M", "H")),
stock_pri_dry = ifelse(stock_pri_dry %in% c("Light", "Moderate", "Heavy", "L", "M", "H"),
substr(stock_pri_dry, 1, 1),
ifelse(stock_pri_dry == "0", "N",
ifelse(stock_pri_dry == "1", "L",
ifelse(stock_pri_dry == "2", "M",
ifelse(stock_pri_dry == "3", "H",
ifelse(stock_pri_dry == "high", "H", NA)))))) %>% as.factor(.) %>% factor(., levels = c("L", "M", "H")),
stock_pri_SF = ifelse(stock_pri_SF %in% c("Light", "Moderate", "Heavy", "L", "M", "H"),
substr(stock_pri_SF, 1, 1),
ifelse(stock_pri_SF == "0", "N",
ifelse(stock_pri_SF == "1", "L",
ifelse(stock_pri_SF == "2", "M",
ifelse(stock_pri_SF == "3", "H",
ifelse(stock_pri_SF == "high", "H", NA)))))) %>% as.factor(.) %>% factor(., levels = c("L", "M", "H")),
stock_pri_dune = ifelse(stock_pri_dune %in% c("Light", "Moderate", "Heavy", "L", "M", "H"),
substr(stock_pri_dune, 1, 1),
ifelse(stock_pri_dune == "0", "N",
ifelse(stock_pri_dune == "1", "L",
ifelse(stock_pri_dune == "2", "M",
ifelse(stock_pri_dune == "3", "H",
ifelse(stock_pri_dune == "high", "H", NA)))))) %>% as.factor(.) %>% factor(., levels = c("L", "M", "H"))) %>%
# to control for multiple threat surveys per date, summarise by date
group_by(region, site, season, obs_date, obs_date2) %>%
summarise(obs_lon = mean(obs_lon, na.rm = TRUE),
obs_lat = mean(obs_lat, na.rm = TRUE),
# in the case of multiple surveys on a single date at a specific
# site, take the max humans counted, etc., and the highest level of
# prints, etc.
humans = max(humans, na.rm = TRUE),
humans_wet = max(humans_wet, na.rm = TRUE),
humans_dry = max(humans_dry, na.rm = TRUE),
humans_dune = max(humans_dune, na.rm = TRUE),
humans_SF = max(humans_SF, na.rm = TRUE),
hoofed_animals = max(hoofed_animals, na.rm = TRUE),
vehicles = max(vehicles, na.rm = TRUE),
pred_birds = max(pred_birds, na.rm = TRUE),
gulls = max(gulls, na.rm = TRUE),
dogs_off = max(dogs_off, na.rm = TRUE),
dogs_on = max(dogs_on, na.rm = TRUE),
dogs = max(dogs, na.rm = TRUE),
hum_pri_wet = ifelse(all(is.na(hum_pri_wet)), NA,
levels(hum_pri_wet)[max(as.integer(hum_pri_wet), na.rm = TRUE)]),
hum_pri_dry = ifelse(all(is.na(hum_pri_dry)), NA,
levels(hum_pri_dry)[max(as.integer(hum_pri_dry), na.rm = TRUE)]),
hum_pri_dune = ifelse(all(is.na(hum_pri_dune)), NA,
levels(hum_pri_dune)[max(as.integer(hum_pri_dune), na.rm = TRUE)]),
hum_pri_SF = ifelse(all(is.na(hum_pri_SF)), NA,
levels(hum_pri_SF)[max(as.integer(hum_pri_SF), na.rm = TRUE)]),
fox_pri_wet = ifelse(all(is.na(fox_pri_wet)), NA,
levels(fox_pri_wet)[max(as.integer(fox_pri_wet), na.rm = TRUE)]),
fox_pri_dry = ifelse(all(is.na(fox_pri_dry)), NA,
levels(fox_pri_dry)[max(as.integer(fox_pri_dry), na.rm = TRUE)]),
fox_pri_dune = ifelse(all(is.na(fox_pri_dune)), NA,
levels(fox_pri_dune)[max(as.integer(fox_pri_dune), na.rm = TRUE)]),
fox_pri_SF = ifelse(all(is.na(fox_pri_SF)), NA,
levels(fox_pri_SF)[max(as.integer(fox_pri_SF), na.rm = TRUE)]),
dog_pri_wet = ifelse(all(is.na(dog_pri_wet)), NA,
levels(dog_pri_wet)[max(as.integer(dog_pri_wet), na.rm = TRUE)]),
dog_pri_dry = ifelse(all(is.na(dog_pri_dry)), NA,
levels(dog_pri_dry)[max(as.integer(dog_pri_dry), na.rm = TRUE)]),
dog_pri_dune = ifelse(all(is.na(dog_pri_dune)), NA,
levels(dog_pri_dune)[max(as.integer(dog_pri_dune), na.rm = TRUE)]),
dog_pri_SF = ifelse(all(is.na(dog_pri_SF)), NA,
levels(dog_pri_SF)[max(as.integer(dog_pri_SF), na.rm = TRUE)]),
vehicle_pri_wet = ifelse(all(is.na(vehicle_pri_wet)), NA,
levels(vehicle_pri_wet)[max(as.integer(vehicle_pri_wet), na.rm = TRUE)]),
vehicle_pri_dry = ifelse(all(is.na(vehicle_pri_dry)), NA,
levels(vehicle_pri_dry)[max(as.integer(vehicle_pri_dry), na.rm = TRUE)]),
vehicle_pri_dune = ifelse(all(is.na(vehicle_pri_dune)), NA,
levels(vehicle_pri_dune)[max(as.integer(vehicle_pri_dune), na.rm = TRUE)]),
vehicle_pri_SF = ifelse(all(is.na(vehicle_pri_SF)), NA,
levels(vehicle_pri_SF)[max(as.integer(vehicle_pri_SF), na.rm = TRUE)]),
trailbike_pri_wet = ifelse(all(is.na(trailbike_pri_wet)), NA,
levels(trailbike_pri_wet)[max(as.integer(trailbike_pri_wet), na.rm = TRUE)]),
trailbike_pri_dry = ifelse(all(is.na(trailbike_pri_dry)), NA,
levels(trailbike_pri_dry)[max(as.integer(trailbike_pri_dry), na.rm = TRUE)]),
trailbike_pri_dune = ifelse(all(is.na(trailbike_pri_dune)), NA,
levels(trailbike_pri_dune)[max(as.integer(trailbike_pri_dune), na.rm = TRUE)]),
trailbike_pri_SF = ifelse(all(is.na(trailbike_pri_SF)), NA,
levels(trailbike_pri_SF)[max(as.integer(trailbike_pri_SF), na.rm = TRUE)]),
horse_pri_wet = ifelse(all(is.na(horse_pri_wet)), NA,
levels(horse_pri_wet)[max(as.integer(horse_pri_wet), na.rm = TRUE)]),
horse_pri_dry = ifelse(all(is.na(horse_pri_dry)), NA,
levels(horse_pri_dry)[max(as.integer(horse_pri_dry), na.rm = TRUE)]),
horse_pri_dune = ifelse(all(is.na(horse_pri_dune)), NA,
levels(horse_pri_dune)[max(as.integer(horse_pri_dune), na.rm = TRUE)]),
horse_pri_SF = ifelse(all(is.na(horse_pri_SF)), NA,
levels(horse_pri_SF)[max(as.integer(horse_pri_SF), na.rm = TRUE)]),
stock_pri_wet = ifelse(all(is.na(stock_pri_wet)), NA,
levels(stock_pri_wet)[max(as.integer(stock_pri_wet), na.rm = TRUE)]),
stock_pri_dry = ifelse(all(is.na(stock_pri_dry)), NA,
levels(stock_pri_dry)[max(as.integer(stock_pri_dry), na.rm = TRUE)]),
stock_pri_dune = ifelse(all(is.na(stock_pri_dune)), NA,
levels(stock_pri_dune)[max(as.integer(stock_pri_dune), na.rm = TRUE)]),
stock_pri_SF = ifelse(all(is.na(stock_pri_SF)), NA,
levels(stock_pri_SF)[max(as.integer(stock_pri_SF), na.rm = TRUE)])) %>%
# make the print variables a factor
mutate_at(vars(hum_pri_wet, hum_pri_dry, hum_pri_dune, hum_pri_SF,
dog_pri_wet, dog_pri_dry, dog_pri_dune, dog_pri_SF,
fox_pri_wet, fox_pri_dry, fox_pri_dune, fox_pri_SF,
vehicle_pri_wet, vehicle_pri_dry, vehicle_pri_dune, vehicle_pri_SF,
trailbike_pri_wet, trailbike_pri_dry, trailbike_pri_dune, trailbike_pri_SF,
horse_pri_wet, horse_pri_dry, horse_pri_dune, horse_pri_SF,
stock_pri_wet, stock_pri_dry, stock_pri_dune, stock_pri_SF),
~ as.factor(.)) %>%
# specify the level order of the print variables
mutate_at(vars(hum_pri_wet, hum_pri_dry, hum_pri_dune, hum_pri_SF,
dog_pri_wet, dog_pri_dry, dog_pri_dune, dog_pri_SF,
fox_pri_wet, fox_pri_dry, fox_pri_dune, fox_pri_SF,
vehicle_pri_wet, vehicle_pri_dry, vehicle_pri_dune, vehicle_pri_SF,
trailbike_pri_wet, trailbike_pri_dry, trailbike_pri_dune, trailbike_pri_SF,
horse_pri_wet, horse_pri_dry, horse_pri_dune, horse_pri_SF,
stock_pri_wet, stock_pri_dry, stock_pri_dune, stock_pri_SF),
~ factor(., levels = c("L", "M", "H"))) %>%
# summarize the print variables across the wet, dry, dune, and sign/fence micro habitats
mutate(hum_pri = ifelse(all(is.na(hum_pri_wet)) && all(is.na(hum_pri_dry)) &&
all(is.na(hum_pri_dune)) && all(is.na(hum_pri_SF)), NA,
pmax(as.integer(hum_pri_wet), as.integer(hum_pri_dry),
as.integer(hum_pri_dune), as.integer(hum_pri_SF), na.rm = TRUE)),
fox_pri = ifelse(all(is.na(fox_pri_wet)) && all(is.na(fox_pri_dry)) &&
all(is.na(fox_pri_dune)) && all(is.na(fox_pri_SF)), NA,
pmax(as.integer(fox_pri_wet), as.integer(fox_pri_dry),
as.integer(fox_pri_dune), as.integer(fox_pri_SF), na.rm = TRUE)),
dog_pri = ifelse(all(is.na(dog_pri_wet)) && all(is.na(dog_pri_dry)) &&
all(is.na(dog_pri_dune)) && all(is.na(dog_pri_SF)), NA,
pmax(as.integer(dog_pri_wet), as.integer(dog_pri_dry),
as.integer(dog_pri_dune), as.integer(dog_pri_SF), na.rm = TRUE)),
vehicle_pri = ifelse(all(is.na(vehicle_pri_wet)) && all(is.na(vehicle_pri_dry)) &&
all(is.na(vehicle_pri_dune)) && all(is.na(vehicle_pri_SF)) &&
all(is.na(trailbike_pri_wet)) && all(is.na(trailbike_pri_dry)) &&
all(is.na(trailbike_pri_dune)) && all(is.na(trailbike_pri_SF)), NA,
pmax(as.integer(vehicle_pri_wet), as.integer(vehicle_pri_dry),
as.integer(vehicle_pri_dune), as.integer(vehicle_pri_SF),
as.integer(trailbike_pri_wet), as.integer(trailbike_pri_dry),
as.integer(trailbike_pri_dune), as.integer(trailbike_pri_SF), na.rm = TRUE)),
hoofed_pri = ifelse(all(is.na(horse_pri_wet)) && all(is.na(horse_pri_dry)) &&
all(is.na(horse_pri_dune)) && all(is.na(horse_pri_SF)) &&
all(is.na(stock_pri_wet)) && all(is.na(stock_pri_dry)) &&
all(is.na(stock_pri_dune)) && all(is.na(stock_pri_SF)), NA,
pmax(as.integer(horse_pri_wet), as.integer(horse_pri_dry),
as.integer(horse_pri_dune), as.integer(horse_pri_SF),
as.integer(stock_pri_wet), as.integer(stock_pri_dry),
as.integer(stock_pri_dune), as.integer(stock_pri_SF), na.rm = TRUE))) %>%
# consolidate the threat data into a clean dataframe
dplyr::select(region, site, season, obs_date, obs_date2, obs_lon, obs_lat,
humans, vehicles, dogs, dogs_on, dogs_off, hoofed_animals, pred_birds,
gulls, hum_pri, fox_pri, dog_pri, vehicle_pri, hoofed_pri) %>%
ungroup()
saveRDS(threat_data_, file = "output/threat_data_.rds")determine the 99% quantile limit for each threat (i.e., to remove outlier data) - shown as the red vertical line here
# determine the 99% quantile limit for each threat (i.e., to remove outlier data)
threat_data_99_ql <-
threat_data_ %>%
summarise_at(c("humans", "vehicles", "dogs", "dogs_on", "dogs_off", "hoofed_animals", "pred_birds", "gulls"),
~ quantile(.x, probs = c(0.99)))
threat_data_99_ql# A tibble: 1 × 8
humans vehicles dogs dogs_on dogs_off hoofed_animals pred_birds gulls
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 68 5 16 8 10 2 8 200
# check histograms of threat data while inspecting the 99% cut-off
threat_data_ %>%
ggplot() +
geom_histogram(aes(log(humans + 1))) +
geom_vline(xintercept = log(as.numeric(threat_data_99_ql$humans[1])), color = "red") +
luke_themethreat_data_ %>%
ggplot() +
geom_histogram(aes(log(dogs + 1))) +
geom_vline(xintercept = log(as.numeric(threat_data_99_ql$dogs[1])), color = "red") +
luke_themethreat_data_ %>%
ggplot() +
geom_histogram(aes(log(pred_birds + 1))) +
geom_vline(xintercept = log(as.numeric(threat_data_99_ql$pred_birds[1])), color = "red") +
luke_themethreat_data_ %>%
ggplot() +
geom_histogram(aes(log(gulls + 1))) +
geom_vline(xintercept = log(as.numeric(threat_data_99_ql$pred_birds[1])), color = "red") +
luke_themethreat_data_ %>%
ggplot() +
geom_histogram(aes(log(vehicles))) +
geom_vline(xintercept = log(as.numeric(threat_data_99_ql$vehicles[1])), color = "red") +
luke_themethreat_data_ %>%
ggplot() +
geom_histogram(aes(log(dogs_off + 1))) +
geom_vline(xintercept = log(as.numeric(threat_data_99_ql$dogs_off[1])), color = "red") +
luke_themethreat_data_ %>%
ggplot() +
geom_histogram(aes(log(dogs_on + 1))) +
geom_vline(xintercept = log(as.numeric(threat_data_99_ql$dogs_on[1])), color = "red") +
luke_themethreat_data_ %>%
ggplot() +
geom_histogram(aes(hoofed_animals)) +
geom_vline(xintercept = as.numeric(threat_data_99_ql$hoofed_animals[1]), color = "red") +
luke_theme# extract public holidays and merge them to the threat data
#### FP ----
FP_holidays <-
bind_rows(
holiday_aus(2009, state = "SA"),
holiday_aus(2010, state = "SA"),
holiday_aus(2011, state = "SA"),
holiday_aus(2012, state = "SA"),
holiday_aus(2013, state = "SA"),
holiday_aus(2014, state = "SA"),
holiday_aus(2015, state = "SA"),
holiday_aus(2016, state = "SA"),
holiday_aus(2017, state = "SA"),
holiday_aus(2018, state = "SA"),
holiday_aus(2019, state = "SA"),
holiday_aus(2020, state = "SA"),
holiday_aus(2021, state = "SA")) %>%
mutate(event = holiday) %>%
mutate(region = "FP",
end_date = date) %>%
rename(start_date = date) %>%
mutate(year = year(start_date)) %>%
mutate(season = ifelse(month(start_date) < 6, year - 1, year)) %>%
mutate(season = ifelse(month(start_date) >= 6,
paste0(year, substr(year + 1, 3, 4)),
paste0(season, substr(year, 3, 4))))
SA_start_end_holidays <-
read_excel("data/final/final_final/School holiday dates.xlsx",
sheet = "SA Sch. Hol Dates",
col_types = "text") %>%
separate(`Autumn school holiday dates`,
into = paste0("new_col", 1:5), sep = " ") %>%
mutate(autumn_start = as.Date(paste(Year, new_col2, new_col1, sep = "-"),
format = "%Y-%b-%d"),
autumn_end = as.Date(paste(Year, new_col5, new_col4, sep = "-"),
format = "%Y-%b-%d")) %>%
dplyr::select(-c(new_col1:new_col5)) %>%
separate(`Winter school holiday dates`,
into = paste0("new_col", 1:5), sep = " ") %>%
mutate(winter_start = as.Date(paste(Year, new_col2, new_col1, sep = "-"),
format = "%Y-%b-%d"),
winter_end = as.Date(paste(Year, new_col5, new_col4, sep = "-"),
format = "%Y-%b-%d")) %>%
dplyr::select(-c(new_col1:new_col5)) %>%
separate(`Spring school holiday dates`,
into = paste0("new_col", 1:5), sep = " ") %>%
mutate(spring_start = as.Date(paste(Year, new_col2, new_col1, sep = "-"),
format = "%Y-%b-%d"),
spring_end = as.Date(paste(Year, new_col5, new_col4, sep = "-"),
format = "%Y-%b-%d")) %>%
dplyr::select(-c(new_col1:new_col5)) %>%
separate(`Summer school holiday dates`,
into = paste0("new_col", 1:5), sep = " ") %>%
mutate(summer_start = as.Date(paste(Year, new_col2, new_col1, sep = "-"),
format = "%Y-%b-%d"),
summer_end = as.Date(paste(as.character(as.numeric(Year)+1), new_col5, new_col4, sep = "-"),
format = "%Y-%b-%d")) %>%
dplyr::select(-c(Year:Source))
FP_start_school_holidays <-
SA_start_end_holidays %>%
select(autumn_start, winter_start, spring_start, summer_start) %>%
pivot_longer(cols = everything(), names_to = "event") %>%
mutate(event = str_remove(event, "_start")) %>%
mutate(region = "FP") %>%
rename(start_date = value) %>%
mutate(year = year(start_date)) %>%
mutate(season = ifelse(month(start_date) < 6, year - 1, year)) %>%
mutate(season = ifelse(month(start_date) >= 6,
paste0(year, substr(year+1, 3, 4)),
paste0(season, substr(year, 3, 4))))
FP_school_holidays <-
SA_start_end_holidays %>%
select(autumn_end, winter_end, spring_end, summer_end) %>%
pivot_longer(cols = everything(), names_to = "event") %>%
mutate(event = str_remove(event, "_end")) %>%
rename(end_date = value) %>%
mutate(year = year(end_date)) %>%
mutate(season = ifelse(month(end_date) < 6, year - 1, year)) %>%
mutate(season = ifelse(month(end_date) >= 6,
paste0(year, substr(year+1, 3, 4)),
paste0(season, substr(year, 3, 4)))) %>%
left_join(FP_start_school_holidays, ., by = c("season", "event")) %>%
mutate(event = paste(event, "school", sep = "_")) %>%
select(-c(year.x, year.y))
FP_holidays <-
bind_rows(FP_school_holidays, FP_holidays) %>%
select(season, region, event, start_date, end_date) %>%
arrange(start_date)
#### MP ----
MP_holidays <-
bind_rows(
holiday_aus(2006, state = "VIC"),
holiday_aus(2007, state = "VIC"),
holiday_aus(2008, state = "VIC"),
holiday_aus(2009, state = "VIC"),
holiday_aus(2010, state = "VIC"),
holiday_aus(2011, state = "VIC"),
holiday_aus(2012, state = "VIC"),
holiday_aus(2013, state = "VIC"),
holiday_aus(2014, state = "VIC"),
holiday_aus(2015, state = "VIC"),
holiday_aus(2016, state = "VIC"),
holiday_aus(2017, state = "VIC"),
holiday_aus(2018, state = "VIC"),
holiday_aus(2019, state = "VIC"),
holiday_aus(2020, state = "VIC"),
holiday_aus(2021, state = "VIC")) %>%
mutate(event = holiday) %>%
mutate(region = "MP",
end_date = date) %>%
rename(start_date = date) %>%
mutate(year = year(start_date)) %>%
mutate(season = ifelse(month(start_date) < 6, year - 1, year)) %>%
mutate(season = ifelse(month(start_date) >= 6,
paste0(year, substr(year + 1, 3, 4)),
paste0(season, substr(year, 3, 4))))
VIC_start_end_holidays <-
read_excel("data/final/final_final/School holiday dates.xlsx",
sheet = "VIC Sch. Hol. Dates",
col_types = "text") %>%
separate(`Autumn school holiday dates`,
into = paste0("new_col", 1:5), sep = " ") %>%
mutate(autumn_start = as.Date(paste(Year, new_col2, new_col1, sep = "-"),
format = "%Y-%b-%d"),
autumn_end = as.Date(paste(Year, new_col5, new_col4, sep = "-"),
format = "%Y-%b-%d")) %>%
dplyr::select(-c(new_col1:new_col5)) %>%
separate(`Winter school holiday dates`,
into = paste0("new_col", 1:5), sep = " ") %>%
mutate(winter_start = as.Date(paste(Year, new_col2, new_col1, sep = "-"),
format = "%Y-%b-%d"),
winter_end = as.Date(paste(Year, new_col5, new_col4, sep = "-"),
format = "%Y-%b-%d")) %>%
dplyr::select(-c(new_col1:new_col5)) %>%
separate(`Spring school holiday dates`,
into = paste0("new_col", 1:5), sep = " ") %>%
mutate(spring_start = as.Date(paste(Year, new_col2, new_col1, sep = "-"),
format = "%Y-%b-%d"),
spring_end = as.Date(paste(Year, new_col5, new_col4, sep = "-"),
format = "%Y-%b-%d")) %>%
dplyr::select(-c(new_col1:new_col5)) %>%
separate(`Summer school holiday dates`,
into = paste0("new_col", 1:5), sep = " ") %>%
mutate(summer_start = as.Date(paste(Year, new_col2, new_col1, sep = "-"),
format = "%Y-%b-%d"),
summer_end = as.Date(paste(as.character(as.numeric(Year)+1), new_col5, new_col4, sep = "-"),
format = "%Y-%b-%d")) %>%
dplyr::select(-c(Year:Source))
MP_start_school_holidays <-
VIC_start_end_holidays %>%
select(autumn_start, winter_start, spring_start, summer_start) %>%
pivot_longer(cols = everything(), names_to = "event") %>%
mutate(event = str_remove(event, "_start")) %>%
mutate(region = "FP") %>%
rename(start_date = value) %>%
mutate(year = year(start_date)) %>%
mutate(season = ifelse(month(start_date) < 6, year - 1, year)) %>%
mutate(season = ifelse(month(start_date) >= 6,
paste0(year, substr(year+1, 3, 4)),
paste0(season, substr(year, 3, 4))))
MP_school_holidays <-
VIC_start_end_holidays %>%
select(autumn_end, winter_end, spring_end, summer_end) %>%
pivot_longer(cols = everything(), names_to = "event") %>%
mutate(event = str_remove(event, "_end")) %>%
rename(end_date = value) %>%
mutate(year = year(end_date)) %>%
mutate(season = ifelse(month(end_date) < 6, year - 1, year)) %>%
mutate(season = ifelse(month(end_date) >= 6,
paste0(year, substr(year+1, 3, 4)),
paste0(season, substr(year, 3, 4)))) %>%
left_join(MP_start_school_holidays, ., by = c("season", "event")) %>%
mutate(event = paste(event, "school", sep = "_")) %>%
select(-c(year.x, year.y)) %>% arrange(start_date)
MP_holidays <-
bind_rows(MP_school_holidays, MP_holidays) %>%
select(season, region, event, start_date, end_date) %>%
arrange(start_date)
BSC_holidays <-
bind_rows(MP_school_holidays, MP_holidays) %>%
select(season, region, event, start_date, end_date) %>%
arrange(start_date) %>%
mutate(region = "BSC")
holidays <-
bind_rows(FP_holidays, BSC_holidays, MP_holidays)# %>%
# pivot_longer(-c(season:holiday), names_to = "start_end", values_to = "date")threat_data__ <-
threat_data_ %>%
mutate(season_site = paste(season, site, sep = "_"),
weekday = factor(as.factor(weekdays(obs_date)),
levels = c("Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday",
"Sunday"))) %>%
rename(date = obs_date) %>%
left_join(., holidays, by = c("region", "season"), relationship = "many-to-many") %>%
mutate(holiday = ifelse(date >= start_date & date <= end_date, 1, 0)) %>%
# dplyr::select(region, season, site, date, start_date, end_date, event, holiday) %>% distinct() %>%
group_by(region, season, site, date) %>%
mutate(holiday = max(holiday, na.rm = TRUE)) %>%
dplyr::select(-c(event, start_date, end_date)) %>%
distinct() %>%
ungroup() %>%
mutate(day_type = ifelse(holiday == 1 | weekday %in%
c("Saturday", "Sunday"), "funday", "workday")) %>%
mutate(funday = ifelse(day_type == "funday", 1, 0)) %>%
mutate(humans_ = ifelse(humans > as.numeric(threat_data_99_ql$humans[1]), NA, humans),
vehicles_ = ifelse(vehicles > as.numeric(threat_data_99_ql$vehicles[1]), NA, vehicles),
dogs_ = ifelse(dogs > as.numeric(threat_data_99_ql$dogs[1]), NA, dogs),
dogs_off_ = ifelse(dogs_off > as.numeric(threat_data_99_ql$dogs_off[1]), NA, dogs_off),
dogs_on_ = ifelse(dogs_on > as.numeric(threat_data_99_ql$dogs_on[1]), NA, dogs_on),
hoofed_animals_ = ifelse(hoofed_animals > as.numeric(threat_data_99_ql$hoofed_animals[1]), NA, hoofed_animals),
pred_birds_ = ifelse(pred_birds > as.numeric(threat_data_99_ql$pred_birds[1]), NA, pred_birds),
gulls_ = ifelse(gulls > as.numeric(threat_data_99_ql$gulls[1]), NA, pred_birds)) %>%
mutate(weekdayN = as.numeric(weekday) - 1) %>%
mutate(weekdayC = circular::circular(weekdayN, type = "angles", units = "radians")) %>%
filter(!is.na(weekday))
threat_data__ %>%
ggplot() +
geom_histogram(aes(funday)) +
# geom_vline(xintercept = log(10), color = "red") +
luke_themetest if weekends and holidays have more threat counts than other days using zero-inflated models. For all threats, there are more counted on weekends and holidays than during the week, except for vehicles (which occur randomly across the week)
#### test if weekends and holidays have more threat counts than other days
# use a zero-inflated model (https://stats.oarc.ucla.edu/r/dae/zip/)
# for all threats, there are more counted on weekends and holidays than during the week,
# except for vehicles (which occur randomly across the week)
mod_hum_zi <- pscl::zeroinfl(humans_ ~ day_type, data = threat_data__, dist = "poisson")
summary(mod_hum_zi)
Call:
pscl::zeroinfl(formula = humans_ ~ day_type, data = threat_data__, dist = "poisson")
Pearson residuals:
Min 1Q Median 3Q Max
-1.1236 -0.7851 -0.7851 0.1056 19.1058
Count model coefficients (poisson with log link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) 2.310064 0.003185 725.3 <2e-16 ***
day_typeworkday -0.529198 0.005095 -103.9 <2e-16 ***
Zero-inflation model coefficients (binomial with logit link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.46151 0.01626 -28.39 <2e-16 ***
day_typeworkday 0.68014 0.02078 32.74 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Number of iterations in BFGS optimization: 6
Log-likelihood: -1.427e+05 on 4 Df
mod_dogs_zi <- pscl::zeroinfl(dogs_ ~ day_type, data = threat_data__, dist = "poisson")
summary(mod_dogs_zi)
Call:
pscl::zeroinfl(formula = dogs_ ~ day_type, data = threat_data__, dist = "poisson")
Pearson residuals:
Min 1Q Median 3Q Max
-0.6698 -0.4632 -0.4632 -0.2173 10.3916
Count model coefficients (poisson with log link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.329577 0.006808 195.28 <2e-16 ***
day_typeworkday -0.276947 0.010920 -25.36 <2e-16 ***
Zero-inflation model coefficients (binomial with logit link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.44047 0.01654 26.63 <2e-16 ***
day_typeworkday 0.72168 0.02285 31.59 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Number of iterations in BFGS optimization: 7
Log-likelihood: -5.192e+04 on 4 Df
mod_dogs_on_zi <- pscl::zeroinfl(dogs_on_ ~ day_type, data = threat_data__, dist = "poisson")
summary(mod_dogs_on_zi)
Call:
pscl::zeroinfl(formula = dogs_on_ ~ day_type, data = threat_data__, dist = "poisson")
Pearson residuals:
Min 1Q Median 3Q Max
-0.4720 -0.4720 -0.3072 -0.3072 11.0711
Count model coefficients (poisson with log link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.72395 0.01265 57.23 <2e-16 ***
day_typeworkday -0.31558 0.02223 -14.20 <2e-16 ***
Zero-inflation model coefficients (binomial with logit link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.99189 0.02017 49.17 <2e-16 ***
day_typeworkday 0.79383 0.03062 25.93 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Number of iterations in BFGS optimization: 9
Log-likelihood: -2.743e+04 on 4 Df
mod_dogs_off_zi <- pscl::zeroinfl(dogs_off_ ~ day_type, data = threat_data__, dist = "poisson")
summary(mod_dogs_off_zi)
Call:
pscl::zeroinfl(formula = dogs_off_ ~ day_type, data = threat_data__,
dist = "poisson")
Pearson residuals:
Min 1Q Median 3Q Max
-0.5336 -0.5336 -0.3901 -0.3901 8.4011
Count model coefficients (poisson with log link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.038057 0.009481 109.5 <2e-16 ***
day_typeworkday -0.179554 0.014592 -12.3 <2e-16 ***
Zero-inflation model coefficients (binomial with logit link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.84672 0.01819 46.56 <2e-16 ***
day_typeworkday 0.61595 0.02542 24.23 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Number of iterations in BFGS optimization: 7
Log-likelihood: -3.763e+04 on 4 Df
mod_pred_birds_zi <- pscl::zeroinfl(pred_birds_ ~ day_type, data = threat_data__, dist = "poisson")
summary(mod_pred_birds_zi)
Call:
pscl::zeroinfl(formula = pred_birds_ ~ day_type, data = threat_data__,
dist = "poisson")
Pearson residuals:
Min 1Q Median 3Q Max
-0.3204 -0.3204 -0.3195 -0.3195 7.5754
Count model coefficients (poisson with log link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.911152 0.015696 58.049 <2e-16 ***
day_typeworkday 0.008796 0.020248 0.434 0.664
Zero-inflation model coefficients (binomial with logit link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.896464 0.024886 76.207 <2e-16 ***
day_typeworkday 0.008438 0.032157 0.262 0.793
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Number of iterations in BFGS optimization: 8
Log-likelihood: -2.326e+04 on 4 Df
mod_gulls_zi <- pscl::zeroinfl(gulls_ ~ day_type, data = threat_data__, dist = "poisson")
summary(mod_gulls_zi)
Call:
pscl::zeroinfl(formula = gulls_ ~ day_type, data = threat_data__, dist = "poisson")
Pearson residuals:
Min 1Q Median 3Q Max
-0.3373 -0.3373 -0.3373 -0.3362 75.2656
Count model coefficients (poisson with log link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.26821 0.01224 103.579 <2e-16 ***
day_typeworkday 0.01721 0.01572 1.095 0.274
Zero-inflation model coefficients (binomial with logit link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.90006 0.02386 79.641 <2e-16 ***
day_typeworkday -0.00272 0.03076 -0.088 0.93
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Number of iterations in BFGS optimization: 7
Log-likelihood: -3.116e+04 on 4 Df
mod_vehicles_zi <- pscl::zeroinfl(vehicles_ ~ day_type, data = threat_data__, dist = "poisson")
summary(mod_vehicles_zi)
Call:
pscl::zeroinfl(formula = vehicles_ ~ day_type, data = threat_data__,
dist = "poisson")
Pearson residuals:
Min 1Q Median 3Q Max
-0.1472 -0.1472 -0.1118 -0.1118 15.4480
Count model coefficients (poisson with log link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.640278 0.039127 16.364 <2e-16 ***
day_typeworkday 0.006591 0.056990 0.116 0.908
Zero-inflation model coefficients (binomial with logit link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) 3.39756 0.05044 67.363 < 2e-16 ***
day_typeworkday 0.55639 0.07327 7.594 3.1e-14 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Number of iterations in BFGS optimization: 9
Log-likelihood: -5272 on 4 Df
Fit circular GAM to weekly count data to assess trends over the week.
how do human counts vary over the week?
#### Fit circular GAM to weekly count data ----
mod_hum <-
mgcv::gam(humans_ ~ s(weekdayN, bs = "cc", k = 7), data = threat_data__)
summary(mod_hum)
Family: gaussian
Link function: identity
Formula:
humans_ ~ s(weekdayN, bs = "cc", k = 7)
Parametric coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 4.04593 0.04013 100.8 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Approximate significance of smooth terms:
edf Ref.df F p-value
s(weekdayN) 4.904 5 92.68 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
R-sq.(adj) = 0.0113 Deviance explained = 1.15%
GCV = 64.859 Scale est. = 64.85 n = 40259
# estimate model predictions
newdata_weekdays <-
data.frame(weekdayN = seq(0, 6))
# plot the weekly variation in the human counts
mod_hum_fits <-
predict(mod_hum,
newdata = newdata_weekdays,
type = 'response', se = TRUE)
mod_hum_predicts <-
data.frame(newdata_weekdays, mod_hum_fits) %>%
mutate(lower = fit - 1.96 * se.fit,
upper = fit + 1.96 * se.fit) %>%
left_join(., threat_data__ %>% dplyr::select(weekdayN, weekday) %>% distinct(), by = "weekdayN")
threat_data__ %>%
ggplot() +
gghalves::geom_half_point(aes(x = weekday, y = log(humans_ + 1)),
size = 1,
width = 0.5,
side = "l",
range_scale = .4,
alpha = 0.1, color = "grey70"
) +
gghalves::geom_half_boxplot(aes(x = weekday, y = log(humans_ + 1)),
size = 0.5,
width = 0.5,
side = "r",
alpha = 0.1, outlier.color = NA, color = "grey70"
) +
# geom_smooth(aes(x = as.numeric(weekday), y = humans_),
# method = lm,
# formula = y ~ splines::bs(x, 5)) +
geom_ribbon(data = mod_hum_predicts,
aes(x = as.numeric(weekday), ymin = log(lower + 1), ymax = log(upper + 1))) +
geom_line(data = mod_hum_predicts, aes(x = as.numeric(weekday), y = log(fit + 1)), color = "white") +
luke_theme +
xlab("day of the week") +
ylab("number of humans counted (log)")how do dog counts vary over the week?
mod_dogs <-
mgcv::gam(dogs_ ~ s(weekdayN, bs = "cc", k = 7), data = threat_data__)
summary(mod_dogs)
Family: gaussian
Link function: identity
Formula:
dogs_ ~ s(weekdayN, bs = "cc", k = 7)
Parametric coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.99916 0.01125 88.85 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Approximate significance of smooth terms:
edf Ref.df F p-value
s(weekdayN) 4.668 5 32.66 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
R-sq.(adj) = 0.00401 Deviance explained = 0.412%
GCV = 5.0955 Scale est. = 5.0948 n = 40286
# plot the weekly variation in the dog counts
mod_dogs_fits <-
predict(mod_dogs,
newdata = newdata_weekdays,
type = 'response', se = TRUE)
mod_dogs_predicts <-
data.frame(newdata_weekdays, mod_dogs_fits) %>%
mutate(lower = fit - 1.96 * se.fit,
upper = fit + 1.96 * se.fit) %>%
left_join(., threat_data__ %>% dplyr::select(weekdayN, weekday) %>% distinct(), by = "weekdayN")
threat_data__ %>%
ggplot() +
gghalves::geom_half_point(aes(x = weekday, y = log(dogs_ + 1)),
size = 1,
width = 0.5,
side = "l",
range_scale = .4,
alpha = 0.1
) +
gghalves::geom_half_boxplot(aes(x = weekday, y = log(dogs_ + 1)),
size = 0.5,
width = 0.5,
side = "r",
alpha = 0.1, outlier.color = NA
) +
geom_ribbon(data = mod_dogs_predicts,
aes(x = as.numeric(weekday), ymin = log(lower + 1), ymax = log(upper + 1))) +
geom_line(data = mod_dogs_predicts, aes(x = as.numeric(weekday), y = log(fit + 1)), color = "white") +
# geom_smooth(aes(x = as.numeric(weekday), y = dogs_), method = lm, formula = y ~ splines::bs(x, 5)) +
luke_theme +
xlab("day of the week") +
ylab("number of dogs counted (log)")how do dogs on leash counts vary over the week?
mod_dogs_on <-
mgcv::gam(dogs_on_ ~ s(weekdayN, bs = "cc", k = 7), data = threat_data__)
summary(mod_dogs_on)
Family: gaussian
Link function: identity
Formula:
dogs_on_ ~ s(weekdayN, bs = "cc", k = 7)
Parametric coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.351871 0.005073 69.36 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Approximate significance of smooth terms:
edf Ref.df F p-value
s(weekdayN) 4.612 5 25.6 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
R-sq.(adj) = 0.00313 Deviance explained = 0.324%
GCV = 1.0371 Scale est. = 1.0369 n = 40296
# plot the weekly variation in the dog on leash counts
mod_dogs_on_fits <-
predict(mod_dogs_on,
newdata = newdata_weekdays,
type = 'response', se = TRUE)
mod_dogs_on_predicts <-
data.frame(newdata_weekdays, mod_dogs_on_fits) %>%
mutate(lower = fit - 1.96 * se.fit,
upper = fit + 1.96 * se.fit) %>%
left_join(., threat_data__ %>% dplyr::select(weekdayN, weekday) %>% distinct(), by = "weekdayN")
threat_data__ %>%
ggplot() +
gghalves::geom_half_point(aes(x = weekday, y = log(dogs_on_ + 1)),
size = 1,
width = 0.5,
side = "l",
range_scale = .4,
alpha = 0.1
) +
gghalves::geom_half_boxplot(aes(x = weekday, y = log(dogs_on_ + 1)),
size = 0.5,
width = 0.5,
side = "r",
alpha = 0.1, outlier.color = NA
) +
geom_ribbon(data = mod_dogs_on_predicts,
aes(x = as.numeric(weekday), ymin = log(lower + 1), ymax = log(upper + 1))) +
geom_line(data = mod_dogs_on_predicts, aes(x = as.numeric(weekday), y = log(fit + 1)), color = "white") +
# geom_smooth(aes(x = as.numeric(weekday), y = dogs_on_), method = lm, formula = y ~ splines::bs(x, 5)) +
luke_theme +
xlab("day of the week") +
ylab("number of dogs on leashes counted (log)")how do dogs off leash counts vary over the week?
mod_dogs_off <-
mgcv::gam(dogs_off_ ~ s(weekdayN, bs = "cc", k = 7), data = threat_data__)
summary(mod_dogs_off)
Family: gaussian
Link function: identity
Formula:
dogs_off_ ~ s(weekdayN, bs = "cc", k = 7)
Parametric coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.603914 0.007546 80.03 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Approximate significance of smooth terms:
edf Ref.df F p-value
s(weekdayN) 4.258 5 21.36 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
R-sq.(adj) = 0.00263 Deviance explained = 0.274%
GCV = 2.2934 Scale est. = 2.2931 n = 40269
# plot the weekly variation in the dog off leash counts
mod_dogs_off_fits <-
predict(mod_dogs_off,
newdata = newdata_weekdays,
type = 'response', se = TRUE)
mod_dogs_off_predicts <-
data.frame(newdata_weekdays, mod_dogs_off_fits) %>%
mutate(lower = fit - 1.96 * se.fit,
upper = fit + 1.96 * se.fit) %>%
left_join(., threat_data__ %>% dplyr::select(weekdayN, weekday) %>% distinct(), by = "weekdayN")
threat_data__ %>%
ggplot() +
gghalves::geom_half_point(aes(x = weekday, y = log(dogs_off_ + 1)),
size = 1,
width = 0.5,
side = "l",
range_scale = .4,
alpha = 0.1
) +
gghalves::geom_half_boxplot(aes(x = weekday, y = log(dogs_off_ + 1)),
size = 0.5,
width = 0.5,
side = "r",
alpha = 0.1, outlier.color = NA
) +
geom_ribbon(data = mod_dogs_off_predicts,
aes(x = as.numeric(weekday), ymin = log(lower + 1), ymax = log(upper + 1))) +
geom_line(data = mod_dogs_off_predicts, aes(x = as.numeric(weekday), y = log(fit + 1)), color = "white") +
# geom_smooth(aes(x = as.numeric(weekday), y = dogs_off_), method = lm, formula = y ~ splines::bs(x, 5)) +
luke_theme +
xlab("day of the week") +
ylab("number of dogs off leashes counted (log)")how do corvid counts vary over the week?
mod_pred_birds <-
mgcv::gam(pred_birds_ ~ s(weekdayN, bs = "cc", k = 7), data = threat_data__)
summary(mod_pred_birds)
Family: gaussian
Link function: identity
Formula:
pred_birds_ ~ s(weekdayN, bs = "cc", k = 7)
Parametric coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.324884 0.005275 61.59 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Approximate significance of smooth terms:
edf Ref.df F p-value
s(weekdayN) 4.152 5 2.486 0.0116 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
R-sq.(adj) = 0.000257 Deviance explained = 0.036%
GCV = 1.1221 Scale est. = 1.122 n = 40319
# plot the weekly variation in the predatory bird counts
mod_pred_birds_fits <-
predict(mod_pred_birds,
newdata = newdata_weekdays,
type = 'response', se = TRUE)
mod_pred_birds_predicts <-
data.frame(newdata_weekdays, mod_pred_birds_fits) %>%
mutate(lower = fit - 1.96 * se.fit,
upper = fit + 1.96 * se.fit) %>%
left_join(., threat_data__ %>% dplyr::select(weekdayN, weekday) %>% distinct(), by = "weekdayN")
threat_data__ %>%
ggplot() +
gghalves::geom_half_point(aes(x = weekday, y = log(pred_birds_ + 1)),
size = 1,
width = 0.5,
side = "l",
range_scale = .4,
alpha = 0.1
) +
gghalves::geom_half_boxplot(aes(x = weekday, y = log(pred_birds_ + 1)),
size = 0.5,
width = 0.5,
side = "r",
alpha = 0.1, outlier.color = NA
) +
geom_ribbon(data = mod_pred_birds_predicts,
aes(x = as.numeric(weekday), ymin = log(lower + 1), ymax = log(upper + 1))) +
geom_line(data = mod_pred_birds_predicts, aes(x = as.numeric(weekday), y = log(fit + 1)), color = "white") +
# geom_smooth(aes(x = as.numeric(weekday), y = pred_birds_), method = lm, formula = y ~ splines::bs(x, 5)) +
luke_theme +
xlab("day of the week") +
ylab("number of corvids counted (log)")how do gulls counts vary over the week?
mod_pred_birds <-
mgcv::gam(gulls_ ~ s(weekdayN, bs = "cc", k = 7), data = threat_data__)
summary(mod_pred_birds)
Family: gaussian
Link function: identity
Formula:
gulls_ ~ s(weekdayN, bs = "cc", k = 7)
Parametric coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.46794 0.01126 41.56 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Approximate significance of smooth terms:
edf Ref.df F p-value
s(weekdayN) 3.739 5 2.177 0.0153 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
R-sq.(adj) = 0.000236 Deviance explained = 0.0328%
GCV = 5.1138 Scale est. = 5.1132 n = 40341
# plot the weekly variation in the predatory bird counts
mod_gulls_fits <-
predict(mod_pred_birds,
newdata = newdata_weekdays,
type = 'response', se = TRUE)
mod_gulls_predicts <-
data.frame(newdata_weekdays, mod_gulls_fits) %>%
mutate(lower = fit - 1.96 * se.fit,
upper = fit + 1.96 * se.fit) %>%
left_join(., threat_data__ %>% dplyr::select(weekdayN, weekday) %>% distinct(), by = "weekdayN")
threat_data__ %>%
ggplot() +
gghalves::geom_half_point(aes(x = weekday, y = log(gulls_ + 1)),
size = 1,
width = 0.5,
side = "l",
range_scale = .4,
alpha = 0.1
) +
gghalves::geom_half_boxplot(aes(x = weekday, y = log(gulls_ + 1)),
size = 0.5,
width = 0.5,
side = "r",
alpha = 0.1, outlier.color = NA
) +
geom_ribbon(data = mod_gulls_predicts,
aes(x = as.numeric(weekday), ymin = log(lower + 1), ymax = log(upper + 1))) +
geom_line(data = mod_gulls_predicts, aes(x = as.numeric(weekday), y = log(fit + 1)), color = "white") +
# geom_smooth(aes(x = as.numeric(weekday), y = gulls_), method = lm, formula = y ~ splines::bs(x, 5)) +
luke_theme +
xlab("day of the week") +
ylab("number of gulls counted (log)")how do vehicle counts vary over the week?
mod_vehicles <-
mgcv::gam(vehicles_ ~ s(weekdayN, bs = "cc", k = 7), data = threat_data__)
summary(mod_vehicles)
Family: gaussian
Link function: identity
Formula:
vehicles_ ~ s(weekdayN, bs = "cc", k = 7)
Parametric coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.046053 0.001844 24.98 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Approximate significance of smooth terms:
edf Ref.df F p-value
s(weekdayN) 3.437 5 1.392 0.079 .
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
R-sq.(adj) = 0.000134 Deviance explained = 0.022%
GCV = 0.13683 Scale est. = 0.13682 n = 40258
# plot the weekly variation in the vehicle counts
mod_vehicles_fits <-
predict(mod_vehicles,
newdata = newdata_weekdays,
type = 'response', se = TRUE)
mod_vehicles_predicts <-
data.frame(newdata_weekdays, mod_vehicles_fits) %>%
mutate(lower = fit - 1.96 * se.fit,
upper = fit + 1.96 * se.fit) %>%
left_join(., threat_data__ %>% dplyr::select(weekdayN, weekday) %>% distinct(), by = "weekdayN")
threat_data__ %>%
ggplot() +
gghalves::geom_half_point(aes(x = weekday, y = vehicles_),
size = 1,
width = 0.5,
side = "l",
range_scale = .4,
alpha = 0.1
) +
gghalves::geom_half_boxplot(aes(x = weekday, y = vehicles_),
size = 0.5,
width = 0.5,
side = "r",
alpha = 0.1, outlier.color = NA
) +
geom_ribbon(data = mod_vehicles_predicts,
aes(x = as.numeric(weekday), ymin = lower, ymax = upper)) +
geom_line(data = mod_vehicles_predicts, aes(x = as.numeric(weekday), y = fit), color = "white") +
# geom_smooth(aes(x = as.numeric(weekday), y = vehicles_), method = lm, formula = y ~ splines::bs(x, 5)) +
luke_theme +
xlab("day of the week") +
ylab("number of vehicles counted")Inspect the weekly variation in human prints
# plot the weekly variation in the human print detections
threat_data__ %>%
ggplot() +
gghalves::geom_half_point(aes(x = weekday, y = hum_pri),
size = 1,
width = 0.5,
side = "l",
range_scale = .4,
alpha = 0.1
) +
gghalves::geom_half_boxplot(aes(x = weekday, y = hum_pri),
size = 0.5,
width = 0.5,
side = "r",
alpha = 0.1, outlier.color = NA
) +
geom_smooth(aes(x = as.numeric(weekday), y = hum_pri), method = lm, formula = y ~ splines::bs(x, 5)) +
luke_theme +
xlab("day of the week") +
ylab("level of human prints recorded")Inspect the weekly variation in dog prints
# plot the weekly variation in the dog print detections
threat_data__ %>%
ggplot() +
gghalves::geom_half_point(aes(x = weekday, y = dog_pri),
size = 1,
width = 0.5,
side = "l",
range_scale = .4,
alpha = 0.1
) +
gghalves::geom_half_boxplot(aes(x = weekday, y = dog_pri),
size = 0.5,
width = 0.5,
side = "r",
alpha = 0.1, outlier.color = NA
) +
geom_smooth(aes(x = as.numeric(weekday), y = dog_pri), method = lm, formula = y ~ splines::bs(x, 5)) +
luke_theme +
xlab("day of the week") +
ylab("level of dogs prints recorded")Inspect the weekly variation in vehicle prints
# plot the weekly variation in the vehicle print detections
threat_data__ %>%
ggplot() +
gghalves::geom_half_point(aes(x = weekday, y = vehicle_pri),
size = 1,
width = 0.5,
side = "l",
range_scale = .4,
alpha = 0.1
) +
gghalves::geom_half_boxplot(aes(x = weekday, y = vehicle_pri),
size = 0.5,
width = 0.5,
side = "r",
alpha = 0.1, outlier.color = NA
) +
geom_smooth(aes(x = as.numeric(weekday), y = vehicle_pri), method = lm, formula = y ~ splines::bs(x, 5)) +
luke_theme +
xlab("day of the week") +
ylab("level of vehicle prints recorded")Inspect the weekly variation in fox prints
# plot the weekly variation in the fox print detections
threat_data__ %>%
ggplot() +
gghalves::geom_half_point(aes(x = weekday, y = fox_pri),
size = 1,
width = 0.5,
side = "l",
range_scale = .4,
alpha = 0.1
) +
gghalves::geom_half_boxplot(aes(x = weekday, y = fox_pri),
size = 0.5,
width = 0.5,
side = "r",
alpha = 0.1, outlier.color = NA
) +
geom_smooth(aes(x = as.numeric(weekday), y = fox_pri), method = lm, formula = y ~ splines::bs(x, 5)) +
luke_theme +
xlab("day of the week") +
ylab("level of fox prints recorded")check correlation between counts of the various threats
# check correlation between humans counts
threat_data__ %>%
dplyr::select(humans_, vehicles_, dogs_, pred_birds_) %>%
na.omit() %>%
cor() %>%
corrplot(type = "upper", method = "number", tl.srt = 45)# relationship between human counts and dog counts
threat_data__ %>%
ggplot() +
geom_jitter(aes(x = humans_, y = dogs_), alpha = 0.1) +
geom_smooth(aes(x = humans_, y = dogs_)) +#, method = lm, formula = y ~ splines::bs(x, 2)) +
luke_theme +
xlab("Number of humans counted") +
ylab("Number of dogs counted")# relationship between human counts and corvid counts
threat_data__ %>%
ggplot() +
geom_jitter(aes(x = humans_, y = pred_birds_), alpha = 0.1) +
geom_smooth(aes(x = humans_, y = pred_birds_)) +#, method = lm) +
luke_theme +
xlab("Number of humans counted") +
ylab("Number of corvids counted")# relationship between human counts and gull counts
threat_data__ %>%
ggplot() +
geom_jitter(aes(x = humans_, y = gulls_), alpha = 0.1) +
geom_smooth(aes(x = humans_, y = gulls_)) +#, method = lm) +
luke_theme +
xlab("Number of humans counted") +
ylab("Number of gulls counted")# relationship between human counts and vehicle counts
threat_data__ %>%
ggplot() +
geom_jitter(aes(x = humans_, y = vehicles_), alpha = 0.1) +
geom_smooth(aes(x = humans_, y = vehicles_)) + #, method = lm, formula = y ~ splines::bs(x, 2)) +
luke_theme +
xlab("Number of humans counted") +
ylab("Number of vehicles counted")# determine which territories are in the threat data and the nest data
sites_intersect_FP <-
inner_join(nest_data_FP, threat_data__ %>% filter(region == "FP"), by = c("season", "site"), relationship = "many-to-many") %>%
dplyr::select(season, site) %>% distinct() %>%
mutate(season_site = paste(season, site, sep = "_"))
sites_intersect_MP <-
inner_join(nest_data_MP, threat_data__ %>% filter(region == "MP"), by = c("season", "site"), relationship = "many-to-many") %>%
dplyr::select(season, site) %>% distinct() %>%
mutate(season_site = paste(season, site, sep = "_"))
sites_intersect_BSC <-
inner_join(nest_data_BSC, threat_data__ %>% filter(region == "BSC"), by = c("season", "site"), relationship = "many-to-many") %>%
dplyr::select(season, site) %>% distinct() %>%
mutate(season_site = paste(season, site, sep = "_"))##### Fleurieu Peninsula: summarise threat data
nest_data_FP_with_threat_data <-
nest_data_FP %>%
mutate(season_site = paste(season, site, sep = "_")) %>%
filter(season_site %in% sites_intersect_FP$season_site) %>%
dplyr::select(season, site, region, nest_ID,
FirstFound, LastPresent, LastChecked,
first_found2, last_alive2, last_checked2,
management_status, management_level,
nest_hab, Fate) %>%
rename(status = management_status,
level = management_level) %>%
mutate(level = paste0("L", level)) %>%
mutate(level = factor(level,
levels = c("L0", "L1",
"L2", "L3",
"L4"))) %>%
ungroup() %>%
mutate(
hum_a = NA,
veh_a = NA,
dog_a = NA,
don_a = NA,
dof_a = NA,
hof_a = NA,
pbd_a = NA,
gul_a = NA,
hum_m = NA,
veh_m = NA,
dog_m = NA,
don_m = NA,
dof_m = NA,
hof_m = NA,
pbd_m = NA,
gul_m = NA,
hum_b = NA,
veh_b = NA,
dog_b = NA,
don_b = NA,
dof_b = NA,
pbd_b = NA,
gul_b = NA,
hof_b = NA,
hum_p = NA,
veh_p = NA,
dog_p = NA,
hof_p = NA,
fox_p = NA,
n_surveys = NA,
days_active = NA,
fundays = NA,
uncertain_days = NA,
halfway = NA) %>%
filter(FirstFound <= LastPresent & FirstFound <= LastChecked & LastPresent <= LastChecked) %>%
filter(first_found2 <= last_alive2 & first_found2 <= last_checked2 & last_alive2 <= last_checked2)
FP_threat_data_subset <-
threat_data__ %>%
filter(region == "FP") %>%
mutate(season_site = paste(season, site, sep = "_")) %>%
filter(season_site %in% sites_intersect_FP$season_site) %>%
ungroup()
for(i in 1:nrow(nest_data_FP_with_threat_data)){
FirstFound <- nest_data_FP_with_threat_data$FirstFound[i]
LastPresent <- nest_data_FP_with_threat_data$LastPresent[i]
LastChecked <- nest_data_FP_with_threat_data$LastChecked[i]
FirstFound2 <- nest_data_FP_with_threat_data$first_found2[i]
LastPresent2 <- nest_data_FP_with_threat_data$last_alive2[i]
LastChecked2 <- nest_data_FP_with_threat_data$last_checked2[i]
halfway <- (LastChecked - LastPresent)/2
days_active <- (LastPresent + halfway) - FirstFound
uncertain_days <- LastChecked - LastPresent
site_ <- as.character(nest_data_FP_with_threat_data$site[i])
season_ <- as.character(nest_data_FP_with_threat_data$season[i])
fundays_df <-
data.frame(date = seq(from = LastPresent2, to = LastChecked2, 1)) %>%
# mutate(weekday = weekdays(dates)) %>%
mutate(weekday = factor(as.factor(weekdays(date)),
levels = c("Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday",
"Sunday")),
region = "FP") %>%
mutate(year = year(date)) %>%
mutate(season = ifelse(month(date) < 6, year - 1, year)) %>%
mutate(season = ifelse(month(date) >= 6,
paste0(year, substr(year + 1, 3, 4)),
paste0(season, substr(year, 3, 4)))) %>%
left_join(., holidays, by = c("region", "season"), relationship = "many-to-many") %>%
mutate(holiday = ifelse(date >= start_date & date <= end_date, 1, 0)) %>%
group_by(region, season, date) %>%
mutate(holiday = max(holiday, na.rm = TRUE)) %>%
dplyr::select(-c(event, start_date, end_date)) %>%
distinct() %>%
ungroup() %>%
mutate(day_type = ifelse(holiday == 1 | weekday %in%
c("Saturday", "Sunday"), "funday", "workday")) %>%
mutate(funday = ifelse(day_type == "funday", 1, 0))
FP_threat_data_subset_ <-
FP_threat_data_subset %>%
ungroup() %>%
# data.frame() %>%
# dplyr::filter(as.numeric(obs_date2) >= FirstFound & as.numeric(obs_date2) <= (LastPresent + halfway) & season == season_) %>%
# dplyr::filter(as.numeric(obs_date2) >= LastPresent & as.numeric(obs_date2) <= (LastPresent + halfway) & season == season_) %>%
dplyr::filter(as.numeric(obs_date2) >= LastPresent & as.numeric(obs_date2) <= (LastPresent + (LastChecked - LastPresent)) & season == season_) %>%
dplyr::filter(site == site_)
if(nrow(FP_threat_data_subset_) > 0){
avgeraged_threats <-
FP_threat_data_subset_ %>%
mutate(hum_bi = ifelse(humans > 0 | (!is.na(hum_pri)), 1, 0),
vehicle_bi = ifelse(vehicles > 0 | (!is.na(vehicle_pri)), 1, 0),
dogs_bi = ifelse(dogs > 0 | (!is.na(dog_pri)), 1, 0),
dogs_off_bi = ifelse(dogs_off > 0, 1, 0),
dogs_on_bi = ifelse(dogs_on > 0, 1, 0),
p_birds_bi = ifelse(pred_birds > 0, 1, 0),
gulls_bi = ifelse(gulls > 0, 1, 0),
hoof_bi = ifelse(hoofed_animals > 0 | (!is.na(hoofed_pri)), 1, 0)) %>%
dplyr::summarise(
# fundays = sum(funday),
hum_avg = mean(humans, na.rm = TRUE),
vehicles_avg = mean(vehicles, na.rm = TRUE),
dogs_avg = mean(dogs, na.rm = TRUE),
dogs_on_avg = mean(dogs_on, na.rm = TRUE),
dogs_off_avg = mean(dogs_off, na.rm = TRUE),
hoof_avg = mean(hoofed_animals, na.rm = TRUE),
p_birds_avg = mean(pred_birds, na.rm = TRUE),
gulls_avg = mean(gulls, na.rm = TRUE),
hum_max = max(humans, na.rm = TRUE),
vehicles_max = max(vehicles, na.rm = TRUE),
dogs_max = max(dogs, na.rm = TRUE),
dogs_on_max = max(dogs_on, na.rm = TRUE),
dogs_off_max = max(dogs_off, na.rm = TRUE),
hoof_max = max(hoofed_animals, na.rm = TRUE),
p_birds_max = max(pred_birds, na.rm = TRUE),
gulls_max = max(gulls, na.rm = TRUE),
hum_bi = max(hum_bi, na.rm = TRUE),
vehicle_bi = max(vehicle_bi, na.rm = TRUE),
dogs_bi = max(dogs_bi, na.rm = TRUE),
dogs_on_bi = max(dogs_on_bi, na.rm = TRUE),
dogs_off_bi = max(dogs_off_bi, na.rm = TRUE),
p_birds_bi = max(p_birds_bi, na.rm = TRUE),
gulls_bi = max(gulls_bi, na.rm = TRUE),
hoof_bi = max(hoof_bi, na.rm = TRUE),
hum_pr = max(hum_pri, na.rm = TRUE),
vehicle_pr = max(vehicle_pri, na.rm = TRUE),
dog_pr = max(dog_pri, na.rm = TRUE),
hoof_pr = max(hoofed_pri, na.rm = TRUE),
fox_pr = max(fox_pri, na.rm = TRUE),
n_surveys = n(),
days_active = days_active,
halfway = halfway,
uncertain_days = uncertain_days)
nest_data_FP_with_threat_data$fundays[i] <- sum(fundays_df$funday)
nest_data_FP_with_threat_data$hum_a[i] <- avgeraged_threats$hum_avg
nest_data_FP_with_threat_data$veh_a[i] <- avgeraged_threats$vehicles_avg
nest_data_FP_with_threat_data$dog_a[i] <- avgeraged_threats$dogs_avg
nest_data_FP_with_threat_data$don_a[i] <- avgeraged_threats$dogs_on_avg
nest_data_FP_with_threat_data$dof_a[i] <- avgeraged_threats$dogs_off_avg
nest_data_FP_with_threat_data$hof_a[i] <- avgeraged_threats$hoof_avg
nest_data_FP_with_threat_data$pbd_a[i] <- avgeraged_threats$p_birds_avg
nest_data_FP_with_threat_data$gul_a[i] <- avgeraged_threats$gulls_avg
nest_data_FP_with_threat_data$hum_m[i] <- avgeraged_threats$hum_max
nest_data_FP_with_threat_data$veh_m[i] <- avgeraged_threats$vehicles_max
nest_data_FP_with_threat_data$dog_m[i] <- avgeraged_threats$dogs_max
nest_data_FP_with_threat_data$don_m[i] <- avgeraged_threats$dogs_on_max
nest_data_FP_with_threat_data$dof_m[i] <- avgeraged_threats$dogs_off_max
nest_data_FP_with_threat_data$hof_m[i] <- avgeraged_threats$hoof_max
nest_data_FP_with_threat_data$pbd_m[i] <- avgeraged_threats$p_birds_max
nest_data_FP_with_threat_data$gul_m[i] <- avgeraged_threats$gulls_max
nest_data_FP_with_threat_data$hum_b[i] <- avgeraged_threats$hum_bi
nest_data_FP_with_threat_data$veh_b[i] <- avgeraged_threats$vehicle_bi
nest_data_FP_with_threat_data$dog_b[i] <- avgeraged_threats$dogs_bi
nest_data_FP_with_threat_data$don_b[i] <- avgeraged_threats$dogs_on_bi
nest_data_FP_with_threat_data$dof_b[i] <- avgeraged_threats$dogs_off_bi
nest_data_FP_with_threat_data$pbd_b[i] <- avgeraged_threats$p_birds_bi
nest_data_FP_with_threat_data$hof_b[i] <- avgeraged_threats$hoof_bi
nest_data_FP_with_threat_data$gul_b[i] <- avgeraged_threats$gulls_bi
nest_data_FP_with_threat_data$hum_p[i] <- avgeraged_threats$hum_pr
nest_data_FP_with_threat_data$veh_p[i] <- avgeraged_threats$vehicle_pr
nest_data_FP_with_threat_data$dog_p[i] <- avgeraged_threats$dog_pr
nest_data_FP_with_threat_data$hof_p[i] <- avgeraged_threats$hoof_pr
nest_data_FP_with_threat_data$fox_p[i] <- avgeraged_threats$fox_pr
nest_data_FP_with_threat_data$n_surveys[i] <- avgeraged_threats$n_surveys
nest_data_FP_with_threat_data$days_active[i] <- avgeraged_threats$days_active
nest_data_FP_with_threat_data$halfway[i] <- avgeraged_threats$halfway
nest_data_FP_with_threat_data$uncertain_days[i] <- avgeraged_threats$uncertain_days
}else{
nest_data_FP_with_threat_data$hum_a[i] <- NA
nest_data_FP_with_threat_data$veh_a[i] <- NA
nest_data_FP_with_threat_data$dog_a[i] <- NA
nest_data_FP_with_threat_data$don_a[i] <- NA
nest_data_FP_with_threat_data$dof_a[i] <- NA
nest_data_FP_with_threat_data$hof_a[i] <- NA
nest_data_FP_with_threat_data$pbd_a[i] <- NA
nest_data_FP_with_threat_data$gul_a[i] <- NA
nest_data_FP_with_threat_data$hum_m[i] <- NA
nest_data_FP_with_threat_data$veh_m[i] <- NA
nest_data_FP_with_threat_data$dog_m[i] <- NA
nest_data_FP_with_threat_data$don_m[i] <- NA
nest_data_FP_with_threat_data$dof_m[i] <- NA
nest_data_FP_with_threat_data$hof_m[i] <- NA
nest_data_FP_with_threat_data$pbd_m[i] <- NA
nest_data_FP_with_threat_data$gul_m[i] <- NA
nest_data_FP_with_threat_data$hum_b[i] <- NA
nest_data_FP_with_threat_data$veh_b[i] <- NA
nest_data_FP_with_threat_data$dog_b[i] <- NA
nest_data_FP_with_threat_data$don_b[i] <- NA
nest_data_FP_with_threat_data$dof_b[i] <- NA
nest_data_FP_with_threat_data$pbd_b[i] <- NA
nest_data_FP_with_threat_data$gul_b[i] <- NA
nest_data_FP_with_threat_data$hof_b[i] <- NA
nest_data_FP_with_threat_data$hum_p[i] <- NA
nest_data_FP_with_threat_data$veh_p[i] <- NA
nest_data_FP_with_threat_data$dog_p[i] <- NA
nest_data_FP_with_threat_data$hof_p[i] <- NA
nest_data_FP_with_threat_data$fox_p[i] <- NA
nest_data_FP_with_threat_data$n_surveys[i] <- 0
nest_data_FP_with_threat_data$days_active[i] <- days_active
nest_data_FP_with_threat_data$halfway[i] <- halfway
nest_data_FP_with_threat_data$uncertain_days[i] <- uncertain_days
nest_data_FP_with_threat_data$fundays[i] <- NA
}
}
saveRDS(nest_data_FP_with_threat_data, file = "output/nest_data_FP_with_threat_data.rds")##### Mornington Peninsula: summarise threat data
nest_data_MP_with_threat_data <-
nest_data_MP %>%
mutate(season_site = paste(season, site, sep = "_")) %>%
filter(season_site %in% sites_intersect_MP$season_site) %>%
dplyr::select(season, site, region, nest_ID,
FirstFound, LastPresent, LastChecked,
first_found2, last_alive2, last_checked2,
management_status, management_level,
nest_hab, Fate) %>%
rename(status = management_status,
level = management_level) %>%
mutate(level = paste0("L", level)) %>%
mutate(level = factor(level,
levels = c("L0", "L1",
"L2", "L3",
"L4"))) %>%
ungroup() %>%
mutate(
hum_a = NA,
veh_a = NA,
dog_a = NA,
don_a = NA,
dof_a = NA,
hof_a = NA,
pbd_a = NA,
gul_a = NA,
hum_m = NA,
veh_m = NA,
dog_m = NA,
don_m = NA,
dof_m = NA,
hof_m = NA,
pbd_m = NA,
gul_m = NA,
hum_b = NA,
veh_b = NA,
dog_b = NA,
don_b = NA,
dof_b = NA,
pbd_b = NA,
gul_b = NA,
hof_b = NA,
hum_p = NA,
veh_p = NA,
dog_p = NA,
hof_p = NA,
fox_p = NA,
n_surveys = NA,
days_active = NA,
fundays = NA,
uncertain_days = NA,
halfway = NA) %>%
filter(FirstFound <= LastPresent & FirstFound <= LastChecked & LastPresent <= LastChecked) %>%
filter(first_found2 <= last_alive2 & first_found2 <= last_checked2 & last_alive2 <= last_checked2)
MP_threat_data_subset <-
threat_data__ %>%
filter(region == "MP") %>%
mutate(season_site = paste(season, site, sep = "_")) %>%
filter(season_site %in% sites_intersect_MP$season_site) %>%
ungroup()
for(i in 1:nrow(nest_data_MP_with_threat_data)){
FirstFound <- nest_data_MP_with_threat_data$FirstFound[i]
LastPresent <- nest_data_MP_with_threat_data$LastPresent[i]
LastChecked <- nest_data_MP_with_threat_data$LastChecked[i]
FirstFound2 <- nest_data_MP_with_threat_data$first_found2[i]
LastPresent2 <- nest_data_MP_with_threat_data$last_alive2[i]
LastChecked2 <- nest_data_MP_with_threat_data$last_checked2[i]
halfway <- (LastChecked - LastPresent)/2
days_active <- (LastPresent + halfway) - FirstFound
uncertain_days <- LastChecked - LastPresent
site_ <- as.character(nest_data_MP_with_threat_data$site[i])
season_ <- as.character(nest_data_MP_with_threat_data$season[i])
fundays_df <-
data.frame(date = seq(from = LastPresent2, to = LastChecked2, 1)) %>%
# mutate(weekday = weekdays(dates)) %>%
mutate(weekday = factor(as.factor(weekdays(date)),
levels = c("Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday",
"Sunday")),
region = "MP") %>%
mutate(year = year(date)) %>%
mutate(season = ifelse(month(date) < 6, year - 1, year)) %>%
mutate(season = ifelse(month(date) >= 6,
paste0(year, substr(year + 1, 3, 4)),
paste0(season, substr(year, 3, 4)))) %>%
left_join(., holidays, by = c("region", "season"), relationship = "many-to-many") %>%
mutate(holiday = ifelse(date >= start_date & date <= end_date, 1, 0)) %>%
group_by(region, season, date) %>%
mutate(holiday = max(holiday, na.rm = TRUE)) %>%
dplyr::select(-c(event, start_date, end_date)) %>%
distinct() %>%
ungroup() %>%
mutate(day_type = ifelse(holiday == 1 | weekday %in%
c("Saturday", "Sunday"), "funday", "workday")) %>%
mutate(funday = ifelse(day_type == "funday", 1, 0))
MP_threat_data_subset_ <-
MP_threat_data_subset %>%
ungroup() %>%
# data.frame() %>%
# dplyr::filter(as.numeric(obs_date2) >= FirstFound & as.numeric(obs_date2) <= (LastPresent + halfway) & season == season_) %>%
# dplyr::filter(as.numeric(obs_date2) >= LastPresent & as.numeric(obs_date2) <= (LastPresent + halfway) & season == season_) %>%
dplyr::filter(as.numeric(obs_date2) >= LastPresent & as.numeric(obs_date2) <= (LastPresent + (LastChecked - LastPresent)) & season == season_) %>%
dplyr::filter(site == site_)
if(nrow(MP_threat_data_subset_) > 0){
avgeraged_threats <-
MP_threat_data_subset_ %>%
mutate(hum_bi = ifelse(humans > 0 | (!is.na(hum_pri)), 1, 0),
vehicle_bi = ifelse(vehicles > 0 | (!is.na(vehicle_pri)), 1, 0),
dogs_bi = ifelse(dogs > 0 | (!is.na(dog_pri)), 1, 0),
dogs_off_bi = ifelse(dogs_off > 0, 1, 0),
dogs_on_bi = ifelse(dogs_on > 0, 1, 0),
p_birds_bi = ifelse(pred_birds > 0, 1, 0),
gulls_bi = ifelse(gulls > 0, 1, 0),
hoof_bi = ifelse(hoofed_animals > 0 | (!is.na(hoofed_pri)), 1, 0)) %>%
dplyr::summarise(
# fundays = sum(funday),
hum_avg = mean(humans, na.rm = TRUE),
vehicles_avg = mean(vehicles, na.rm = TRUE),
dogs_avg = mean(dogs, na.rm = TRUE),
dogs_on_avg = mean(dogs_on, na.rm = TRUE),
dogs_off_avg = mean(dogs_off, na.rm = TRUE),
hoof_avg = mean(hoofed_animals, na.rm = TRUE),
p_birds_avg = mean(pred_birds, na.rm = TRUE),
gulls_avg = mean(gulls, na.rm = TRUE),
hum_max = max(humans, na.rm = TRUE),
vehicles_max = max(vehicles, na.rm = TRUE),
dogs_max = max(dogs, na.rm = TRUE),
dogs_on_max = max(dogs_on, na.rm = TRUE),
dogs_off_max = max(dogs_off, na.rm = TRUE),
hoof_max = max(hoofed_animals, na.rm = TRUE),
p_birds_max = max(pred_birds, na.rm = TRUE),
gulls_max = max(gulls, na.rm = TRUE),
hum_bi = max(hum_bi, na.rm = TRUE),
vehicle_bi = max(vehicle_bi, na.rm = TRUE),
dogs_bi = max(dogs_bi, na.rm = TRUE),
dogs_on_bi = max(dogs_on_bi, na.rm = TRUE),
dogs_off_bi = max(dogs_off_bi, na.rm = TRUE),
p_birds_bi = max(p_birds_bi, na.rm = TRUE),
gulls_bi = max(gulls_bi, na.rm = TRUE),
hoof_bi = max(hoof_bi, na.rm = TRUE),
hum_pr = max(hum_pri, na.rm = TRUE),
vehicle_pr = max(vehicle_pri, na.rm = TRUE),
dog_pr = max(dog_pri, na.rm = TRUE),
hoof_pr = max(hoofed_pri, na.rm = TRUE),
fox_pr = max(fox_pri, na.rm = TRUE),
n_surveys = n(),
days_active = days_active,
halfway = halfway,
uncertain_days = uncertain_days)
nest_data_MP_with_threat_data$fundays[i] <- sum(fundays_df$funday)
nest_data_MP_with_threat_data$hum_a[i] <- avgeraged_threats$hum_avg
nest_data_MP_with_threat_data$veh_a[i] <- avgeraged_threats$vehicles_avg
nest_data_MP_with_threat_data$dog_a[i] <- avgeraged_threats$dogs_avg
nest_data_MP_with_threat_data$don_a[i] <- avgeraged_threats$dogs_on_avg
nest_data_MP_with_threat_data$dof_a[i] <- avgeraged_threats$dogs_off_avg
nest_data_MP_with_threat_data$hof_a[i] <- avgeraged_threats$hoof_avg
nest_data_MP_with_threat_data$pbd_a[i] <- avgeraged_threats$p_birds_avg
nest_data_MP_with_threat_data$gul_a[i] <- avgeraged_threats$gulls_avg
nest_data_MP_with_threat_data$hum_m[i] <- avgeraged_threats$hum_max
nest_data_MP_with_threat_data$veh_m[i] <- avgeraged_threats$vehicles_max
nest_data_MP_with_threat_data$dog_m[i] <- avgeraged_threats$dogs_max
nest_data_MP_with_threat_data$don_m[i] <- avgeraged_threats$dogs_on_max
nest_data_MP_with_threat_data$dof_m[i] <- avgeraged_threats$dogs_off_max
nest_data_MP_with_threat_data$hof_m[i] <- avgeraged_threats$hoof_max
nest_data_MP_with_threat_data$pbd_m[i] <- avgeraged_threats$p_birds_max
nest_data_MP_with_threat_data$gul_m[i] <- avgeraged_threats$gulls_max
nest_data_MP_with_threat_data$hum_b[i] <- avgeraged_threats$hum_bi
nest_data_MP_with_threat_data$veh_b[i] <- avgeraged_threats$vehicle_bi
nest_data_MP_with_threat_data$dog_b[i] <- avgeraged_threats$dogs_bi
nest_data_MP_with_threat_data$don_b[i] <- avgeraged_threats$dogs_on_bi
nest_data_MP_with_threat_data$dof_b[i] <- avgeraged_threats$dogs_off_bi
nest_data_MP_with_threat_data$pbd_b[i] <- avgeraged_threats$p_birds_bi
nest_data_MP_with_threat_data$hof_b[i] <- avgeraged_threats$hoof_bi
nest_data_MP_with_threat_data$gul_b[i] <- avgeraged_threats$gulls_bi
nest_data_MP_with_threat_data$hum_p[i] <- avgeraged_threats$hum_pr
nest_data_MP_with_threat_data$veh_p[i] <- avgeraged_threats$vehicle_pr
nest_data_MP_with_threat_data$dog_p[i] <- avgeraged_threats$dog_pr
nest_data_MP_with_threat_data$hof_p[i] <- avgeraged_threats$hoof_pr
nest_data_MP_with_threat_data$fox_p[i] <- avgeraged_threats$fox_pr
nest_data_MP_with_threat_data$n_surveys[i] <- avgeraged_threats$n_surveys
nest_data_MP_with_threat_data$days_active[i] <- avgeraged_threats$days_active
nest_data_MP_with_threat_data$halfway[i] <- avgeraged_threats$halfway
nest_data_MP_with_threat_data$uncertain_days[i] <- avgeraged_threats$uncertain_days
}else{
nest_data_MP_with_threat_data$hum_a[i] <- NA
nest_data_MP_with_threat_data$veh_a[i] <- NA
nest_data_MP_with_threat_data$dog_a[i] <- NA
nest_data_MP_with_threat_data$don_a[i] <- NA
nest_data_MP_with_threat_data$dof_a[i] <- NA
nest_data_MP_with_threat_data$hof_a[i] <- NA
nest_data_MP_with_threat_data$pbd_a[i] <- NA
nest_data_MP_with_threat_data$gul_a[i] <- NA
nest_data_MP_with_threat_data$hum_m[i] <- NA
nest_data_MP_with_threat_data$veh_m[i] <- NA
nest_data_MP_with_threat_data$dog_m[i] <- NA
nest_data_MP_with_threat_data$don_m[i] <- NA
nest_data_MP_with_threat_data$dof_m[i] <- NA
nest_data_MP_with_threat_data$hof_m[i] <- NA
nest_data_MP_with_threat_data$pbd_m[i] <- NA
nest_data_MP_with_threat_data$gul_m[i] <- NA
nest_data_MP_with_threat_data$hum_b[i] <- NA
nest_data_MP_with_threat_data$veh_b[i] <- NA
nest_data_MP_with_threat_data$dog_b[i] <- NA
nest_data_MP_with_threat_data$don_b[i] <- NA
nest_data_MP_with_threat_data$dof_b[i] <- NA
nest_data_MP_with_threat_data$pbd_b[i] <- NA
nest_data_MP_with_threat_data$gul_b[i] <- NA
nest_data_MP_with_threat_data$hof_b[i] <- NA
nest_data_MP_with_threat_data$hum_p[i] <- NA
nest_data_MP_with_threat_data$veh_p[i] <- NA
nest_data_MP_with_threat_data$dog_p[i] <- NA
nest_data_MP_with_threat_data$hof_p[i] <- NA
nest_data_MP_with_threat_data$fox_p[i] <- NA
nest_data_MP_with_threat_data$n_surveys[i] <- 0
nest_data_MP_with_threat_data$days_active[i] <- days_active
nest_data_MP_with_threat_data$halfway[i] <- halfway
nest_data_MP_with_threat_data$uncertain_days[i] <- uncertain_days
nest_data_MP_with_threat_data$fundays[i] <- NA
}
}
saveRDS(nest_data_MP_with_threat_data, file = "output/nest_data_MP_with_threat_data.rds")##### Bellarine / Surf Coast: summarise threat data
nest_data_BSC_with_threat_data <-
nest_data_BSC %>%
mutate(season_site = paste(season, site, sep = "_")) %>%
filter(season_site %in% sites_intersect_BSC$season_site) %>%
dplyr::select(season, site, region, nest_ID,
FirstFound, LastPresent, LastChecked,
first_found2, last_alive2, last_checked2,
management_status, management_level,
nest_hab, Fate) %>%
rename(status = management_status,
level = management_level) %>%
mutate(level = paste0("L", level)) %>%
mutate(level = factor(level,
levels = c("L0", "L1",
"L2", "L3",
"L4"))) %>%
ungroup() %>%
mutate(
hum_a = NA,
veh_a = NA,
dog_a = NA,
don_a = NA,
dof_a = NA,
hof_a = NA,
pbd_a = NA,
gul_a = NA,
hum_m = NA,
veh_m = NA,
dog_m = NA,
don_m = NA,
dof_m = NA,
hof_m = NA,
pbd_m = NA,
gul_m = NA,
hum_b = NA,
veh_b = NA,
dog_b = NA,
don_b = NA,
dof_b = NA,
pbd_b = NA,
gul_b = NA,
hof_b = NA,
hum_p = NA,
veh_p = NA,
dog_p = NA,
hof_p = NA,
fox_p = NA,
n_surveys = NA,
days_active = NA,
fundays = NA,
uncertain_days = NA,
halfway = NA) %>%
filter(FirstFound <= LastPresent & FirstFound <= LastChecked & LastPresent <= LastChecked) %>%
filter(first_found2 <= last_alive2 & first_found2 <= last_checked2 & last_alive2 <= last_checked2)
BSC_threat_data_subset <-
threat_data__ %>%
filter(region == "BSC") %>%
mutate(season_site = paste(season, site, sep = "_")) %>%
filter(season_site %in% sites_intersect_BSC$season_site) %>%
ungroup()
for(i in 1:nrow(nest_data_BSC_with_threat_data)){
FirstFound <- nest_data_BSC_with_threat_data$FirstFound[i]
LastPresent <- nest_data_BSC_with_threat_data$LastPresent[i]
LastChecked <- nest_data_BSC_with_threat_data$LastChecked[i]
FirstFound2 <- nest_data_BSC_with_threat_data$first_found2[i]
LastPresent2 <- nest_data_BSC_with_threat_data$last_alive2[i]
LastChecked2 <- nest_data_BSC_with_threat_data$last_checked2[i]
halfway <- (LastChecked - LastPresent)/2
days_active <- (LastPresent + halfway) - FirstFound
uncertain_days <- LastChecked - LastPresent
site_ <- as.character(nest_data_BSC_with_threat_data$site[i])
season_ <- as.character(nest_data_BSC_with_threat_data$season[i])
fundays_df <-
data.frame(date = seq(from = LastPresent2, to = LastChecked2, 1)) %>%
# mutate(weekday = weekdays(dates)) %>%
mutate(weekday = factor(as.factor(weekdays(date)),
levels = c("Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday",
"Sunday")),
region = "BSC") %>%
mutate(year = year(date)) %>%
mutate(season = ifelse(month(date) < 6, year - 1, year)) %>%
mutate(season = ifelse(month(date) >= 6,
paste0(year, substr(year + 1, 3, 4)),
paste0(season, substr(year, 3, 4)))) %>%
left_join(., holidays, by = c("region", "season"), relationship = "many-to-many") %>%
mutate(holiday = ifelse(date >= start_date & date <= end_date, 1, 0)) %>%
group_by(region, season, date) %>%
mutate(holiday = max(holiday, na.rm = TRUE)) %>%
dplyr::select(-c(event, start_date, end_date)) %>%
distinct() %>%
ungroup() %>%
mutate(day_type = ifelse(holiday == 1 | weekday %in%
c("Saturday", "Sunday"), "funday", "workday")) %>%
mutate(funday = ifelse(day_type == "funday", 1, 0))
BSC_threat_data_subset_ <-
BSC_threat_data_subset %>%
ungroup() %>%
# data.frame() %>%
# dplyr::filter(as.numeric(obs_date2) >= FirstFound & as.numeric(obs_date2) <= (LastPresent + halfway) & season == season_) %>%
# dplyr::filter(as.numeric(obs_date2) >= LastPresent & as.numeric(obs_date2) <= (LastPresent + halfway) & season == season_) %>%
dplyr::filter(as.numeric(obs_date2) >= LastPresent & as.numeric(obs_date2) <= (LastPresent + (LastChecked - LastPresent)) & season == season_) %>%
dplyr::filter(site == site_)
if(nrow(BSC_threat_data_subset_) > 0){
avgeraged_threats <-
BSC_threat_data_subset_ %>%
mutate(hum_bi = ifelse(humans > 0 | (!is.na(hum_pri)), 1, 0),
vehicle_bi = ifelse(vehicles > 0 | (!is.na(vehicle_pri)), 1, 0),
dogs_bi = ifelse(dogs > 0 | (!is.na(dog_pri)), 1, 0),
dogs_off_bi = ifelse(dogs_off > 0, 1, 0),
dogs_on_bi = ifelse(dogs_on > 0, 1, 0),
p_birds_bi = ifelse(pred_birds > 0, 1, 0),
gulls_bi = ifelse(gulls > 0, 1, 0),
hoof_bi = ifelse(hoofed_animals > 0 | (!is.na(hoofed_pri)), 1, 0)) %>%
dplyr::summarise(
# fundays = sum(funday),
hum_avg = mean(humans, na.rm = TRUE),
vehicles_avg = mean(vehicles, na.rm = TRUE),
dogs_avg = mean(dogs, na.rm = TRUE),
dogs_on_avg = mean(dogs_on, na.rm = TRUE),
dogs_off_avg = mean(dogs_off, na.rm = TRUE),
hoof_avg = mean(hoofed_animals, na.rm = TRUE),
p_birds_avg = mean(pred_birds, na.rm = TRUE),
gulls_avg = mean(gulls, na.rm = TRUE),
hum_max = max(humans, na.rm = TRUE),
vehicles_max = max(vehicles, na.rm = TRUE),
dogs_max = max(dogs, na.rm = TRUE),
dogs_on_max = max(dogs_on, na.rm = TRUE),
dogs_off_max = max(dogs_off, na.rm = TRUE),
hoof_max = max(hoofed_animals, na.rm = TRUE),
p_birds_max = max(pred_birds, na.rm = TRUE),
gulls_max = max(gulls, na.rm = TRUE),
hum_bi = max(hum_bi, na.rm = TRUE),
vehicle_bi = max(vehicle_bi, na.rm = TRUE),
dogs_bi = max(dogs_bi, na.rm = TRUE),
dogs_on_bi = max(dogs_on_bi, na.rm = TRUE),
dogs_off_bi = max(dogs_off_bi, na.rm = TRUE),
p_birds_bi = max(p_birds_bi, na.rm = TRUE),
gulls_bi = max(gulls_bi, na.rm = TRUE),
hoof_bi = max(hoof_bi, na.rm = TRUE),
hum_pr = max(hum_pri, na.rm = TRUE),
vehicle_pr = max(vehicle_pri, na.rm = TRUE),
dog_pr = max(dog_pri, na.rm = TRUE),
hoof_pr = max(hoofed_pri, na.rm = TRUE),
fox_pr = max(fox_pri, na.rm = TRUE),
n_surveys = n(),
days_active = days_active,
halfway = halfway,
uncertain_days = uncertain_days)
nest_data_BSC_with_threat_data$fundays[i] <- sum(fundays_df$funday)
nest_data_BSC_with_threat_data$hum_a[i] <- avgeraged_threats$hum_avg
nest_data_BSC_with_threat_data$veh_a[i] <- avgeraged_threats$vehicles_avg
nest_data_BSC_with_threat_data$dog_a[i] <- avgeraged_threats$dogs_avg
nest_data_BSC_with_threat_data$don_a[i] <- avgeraged_threats$dogs_on_avg
nest_data_BSC_with_threat_data$dof_a[i] <- avgeraged_threats$dogs_off_avg
nest_data_BSC_with_threat_data$hof_a[i] <- avgeraged_threats$hoof_avg
nest_data_BSC_with_threat_data$pbd_a[i] <- avgeraged_threats$p_birds_avg
nest_data_BSC_with_threat_data$gul_a[i] <- avgeraged_threats$gulls_avg
nest_data_BSC_with_threat_data$hum_m[i] <- avgeraged_threats$hum_max
nest_data_BSC_with_threat_data$veh_m[i] <- avgeraged_threats$vehicles_max
nest_data_BSC_with_threat_data$dog_m[i] <- avgeraged_threats$dogs_max
nest_data_BSC_with_threat_data$don_m[i] <- avgeraged_threats$dogs_on_max
nest_data_BSC_with_threat_data$dof_m[i] <- avgeraged_threats$dogs_off_max
nest_data_BSC_with_threat_data$hof_m[i] <- avgeraged_threats$hoof_max
nest_data_BSC_with_threat_data$pbd_m[i] <- avgeraged_threats$p_birds_max
nest_data_BSC_with_threat_data$gul_m[i] <- avgeraged_threats$gulls_max
nest_data_BSC_with_threat_data$hum_b[i] <- avgeraged_threats$hum_bi
nest_data_BSC_with_threat_data$veh_b[i] <- avgeraged_threats$vehicle_bi
nest_data_BSC_with_threat_data$dog_b[i] <- avgeraged_threats$dogs_bi
nest_data_BSC_with_threat_data$don_b[i] <- avgeraged_threats$dogs_on_bi
nest_data_BSC_with_threat_data$dof_b[i] <- avgeraged_threats$dogs_off_bi
nest_data_BSC_with_threat_data$pbd_b[i] <- avgeraged_threats$p_birds_bi
nest_data_BSC_with_threat_data$hof_b[i] <- avgeraged_threats$hoof_bi
nest_data_BSC_with_threat_data$gul_b[i] <- avgeraged_threats$gulls_bi
nest_data_BSC_with_threat_data$hum_p[i] <- avgeraged_threats$hum_pr
nest_data_BSC_with_threat_data$veh_p[i] <- avgeraged_threats$vehicle_pr
nest_data_BSC_with_threat_data$dog_p[i] <- avgeraged_threats$dog_pr
nest_data_BSC_with_threat_data$hof_p[i] <- avgeraged_threats$hoof_pr
nest_data_BSC_with_threat_data$fox_p[i] <- avgeraged_threats$fox_pr
nest_data_BSC_with_threat_data$n_surveys[i] <- avgeraged_threats$n_surveys
nest_data_BSC_with_threat_data$days_active[i] <- avgeraged_threats$days_active
nest_data_BSC_with_threat_data$halfway[i] <- avgeraged_threats$halfway
nest_data_BSC_with_threat_data$uncertain_days[i] <- avgeraged_threats$uncertain_days
}else{
nest_data_BSC_with_threat_data$hum_a[i] <- NA
nest_data_BSC_with_threat_data$veh_a[i] <- NA
nest_data_BSC_with_threat_data$dog_a[i] <- NA
nest_data_BSC_with_threat_data$don_a[i] <- NA
nest_data_BSC_with_threat_data$dof_a[i] <- NA
nest_data_BSC_with_threat_data$hof_a[i] <- NA
nest_data_BSC_with_threat_data$pbd_a[i] <- NA
nest_data_BSC_with_threat_data$gul_a[i] <- NA
nest_data_BSC_with_threat_data$hum_m[i] <- NA
nest_data_BSC_with_threat_data$veh_m[i] <- NA
nest_data_BSC_with_threat_data$dog_m[i] <- NA
nest_data_BSC_with_threat_data$don_m[i] <- NA
nest_data_BSC_with_threat_data$dof_m[i] <- NA
nest_data_BSC_with_threat_data$hof_m[i] <- NA
nest_data_BSC_with_threat_data$pbd_m[i] <- NA
nest_data_BSC_with_threat_data$gul_m[i] <- NA
nest_data_BSC_with_threat_data$hum_b[i] <- NA
nest_data_BSC_with_threat_data$veh_b[i] <- NA
nest_data_BSC_with_threat_data$dog_b[i] <- NA
nest_data_BSC_with_threat_data$don_b[i] <- NA
nest_data_BSC_with_threat_data$dof_b[i] <- NA
nest_data_BSC_with_threat_data$pbd_b[i] <- NA
nest_data_BSC_with_threat_data$gul_b[i] <- NA
nest_data_BSC_with_threat_data$hof_b[i] <- NA
nest_data_BSC_with_threat_data$hum_p[i] <- NA
nest_data_BSC_with_threat_data$veh_p[i] <- NA
nest_data_BSC_with_threat_data$dog_p[i] <- NA
nest_data_BSC_with_threat_data$hof_p[i] <- NA
nest_data_BSC_with_threat_data$fox_p[i] <- NA
nest_data_BSC_with_threat_data$n_surveys[i] <- 0
nest_data_BSC_with_threat_data$days_active[i] <- days_active
nest_data_BSC_with_threat_data$halfway[i] <- halfway
nest_data_BSC_with_threat_data$uncertain_days[i] <- uncertain_days
nest_data_BSC_with_threat_data$fundays[i] <- NA
}
}
saveRDS(nest_data_BSC_with_threat_data, file = "output/nest_data_BSC_with_threat_data.rds")remove outlier data and those with very infrequent threat surveys (cut off: visited at least once per week)
##### remove outlier data and those with very infrequent threat surveys
nest_data_with_threat_data <-
bind_rows(nest_data_FP_with_threat_data,
nest_data_MP_with_threat_data,
nest_data_BSC_with_threat_data) %>%
filter(n_surveys > 0) %>%
# mutate(dof_b = ifelse(dof_b == 1, "Y", "N")) %>%
# dplyr::select(-fox_p) %>%
mutate_at(vars(hum_b, veh_b, dog_b, don_b, dof_b, pbd_b, gul_b, hof_b),
~ as.factor(.)) %>%
mutate_at(vars(hum_p, veh_p, dog_p, hof_p, fox_p),
~ ifelse(is.na(.), 0, .))
# nest_data_with_threat_data %>% filter(fundays > 10) %>% dplyr::select(fundays) %>% arrange(desc(fundays))
# nest_data_with_threat_data %>%
# filter()
# nest_data_with_threat_data %>%
# # filter(fundays <= 25) %>%
# ggplot() +
# geom_histogram(aes(fundays)) +
# # geom_vline(xintercept = log(10), color = "red") +
# luke_theme
nest_data_with_threat_data %>%
ggplot() +
geom_histogram(aes(halfway/n_surveys), binwidth = 1) +
geom_vline(xintercept = 7, color = "red") +
luke_themenest_data_with_threat_data_7d <-
nest_data_with_threat_data %>%
filter(halfway/n_surveys <= 7) %>%
filter(fundays < 100)
# nest_data_with_threat_data
#### check variable distributions and collinearity ----
# determine the 99% quantile limit for each threat (i.e., to remove outlier data)
threat_data_99_ql_ <-
nest_data_with_threat_data_7d %>%
summarise_at(c("hum_a", "pbd_a", "gul_a", "veh_a", "dog_a", "don_a", "dof_a",
"hum_m", "pbd_m", "gul_m", "veh_m", "dog_m", "don_m", "dof_m",
"hum_p", "veh_p", "dog_p", "hof_p", "fox_p"),
~ quantile(.x, probs = c(0.99)))
nest_data_with_threat_data_7d %>%
filter(hum_a <= ceiling(as.numeric(threat_data_99_ql_$hum_a[1]))) %>%
ggplot() +
geom_histogram(aes(hum_a), binwidth = 5) +
luke_theme +
xlab("average number of humans counted in territory during active nest")nest_data_with_threat_data_7d %>%
filter(veh_a <= ceiling(as.numeric(threat_data_99_ql_$veh_a[1]))) %>%
ggplot() +
geom_histogram(aes(veh_a), binwidth = 1) +
luke_theme +
xlab("average number of vehicles counted in territory during active nest")nest_data_with_threat_data_7d %>%
filter(dog_a <= ceiling(as.numeric(threat_data_99_ql_$dog_a[1]))) %>%
ggplot() +
geom_histogram(aes(dog_a), binwidth = 1) +
luke_theme +
xlab("average number of dogs counted in territory during active nest")nest_data_with_threat_data_7d %>%
filter(don_a <= ceiling(as.numeric(threat_data_99_ql_$don_a[1]))) %>%
ggplot() +
geom_histogram(aes(don_a), binwidth = 1) +
luke_theme +
xlab("average number of dogs on leashes counted in territory during active nest")nest_data_with_threat_data_7d %>%
filter(dof_a <= ceiling(as.numeric(threat_data_99_ql_$dof_a[1]))) %>%
ggplot() +
geom_histogram(aes(dof_a), binwidth = 1) +
luke_theme +
xlab("average number of dogs off leashes counted in territory during active nest")nest_data_with_threat_data_7d %>%
filter(dof_a <= ceiling(as.numeric(threat_data_99_ql_$pbd_a[1]))) %>%
ggplot() +
geom_histogram(aes(pbd_a), binwidth = 1) +
luke_theme +
xlab("average number of corvids counted in territory during active nest")nest_data_with_threat_data_7d %>%
filter(dof_a <= ceiling(as.numeric(threat_data_99_ql_$gul_a[1]))) %>%
ggplot() +
geom_histogram(aes(gul_a), binwidth = 1) +
luke_theme +
xlab("average number of gulls counted in territory during active nest")nest_data_with_threat_data_7d %>%
filter(hum_m <= ceiling(as.numeric(threat_data_99_ql_$hum_m[1]))) %>%
ggplot() +
geom_histogram(aes(hum_m), binwidth = 1) +
luke_theme +
xlab("maximum number of humans counted in territory during active nest")nest_data_with_threat_data_7d %>%
filter(veh_m <= ceiling(as.numeric(threat_data_99_ql_$veh_m[1]))) %>%
ggplot() +
geom_histogram(aes(veh_m), binwidth = 1) +
luke_theme +
xlab("maximum number of vehicles counted in territory during active nest")nest_data_with_threat_data_7d %>%
filter(dog_m <= ceiling(as.numeric(threat_data_99_ql_$dog_m[1]))) %>%
ggplot() +
geom_histogram(aes(dog_m), binwidth = 1) +
luke_theme +
xlab("maximum number of dogs counted in territory during active nest")nest_data_with_threat_data_7d %>%
filter(don_m <= ceiling(as.numeric(threat_data_99_ql_$don_m[1]))) %>%
ggplot() +
geom_histogram(aes(don_m), binwidth = 1) +
luke_theme +
xlab("maximum number of dogs on leashes counted in territory during active nest")nest_data_with_threat_data_7d %>%
filter(dof_m <= ceiling(as.numeric(threat_data_99_ql_$dof_m[1]))) %>%
ggplot() +
geom_histogram(aes(dof_m), binwidth = 1) +
luke_theme +
xlab("maximum number of dogs off leashes counted in territory during active nest")nest_data_with_threat_data_7d %>%
filter(dof_a <= ceiling(as.numeric(threat_data_99_ql_$pbd_m[1]))) %>%
ggplot() +
geom_histogram(aes(pbd_m), binwidth = 1) +
luke_theme +
xlab("maximum number of corvids counted in territory during active nest")nest_data_with_threat_data_7d %>%
filter(dof_a <= ceiling(as.numeric(threat_data_99_ql_$gul_m[1]))) %>%
ggplot() +
geom_histogram(aes(gul_m), binwidth = 1) +
luke_theme +
xlab("maximum number of gulls counted in territory during active nest")nest_data_with_threat_data_7d %>%
filter(hum_p <= ceiling(as.numeric(threat_data_99_ql_$hum_p[1]))) %>%
ggplot() +
geom_histogram(aes(hum_p), binwidth = 1) +
luke_theme +
xlab("maximum human print level detected in territory during active nest")nest_data_with_threat_data_7d %>%
filter(veh_p < ceiling(as.numeric(threat_data_99_ql_$veh_p[1]))) %>%
ggplot() +
geom_histogram(aes(veh_p), binwidth = 1) +
luke_theme +
xlab("maximum vehicle print level detected in territory during active nest")nest_data_with_threat_data_7d %>%
filter(dog_p <= ceiling(as.numeric(threat_data_99_ql_$dog_p[1]))) %>%
ggplot() +
geom_histogram(aes(dog_p), binwidth = 1) +
luke_theme +
xlab("maximum dog print level detected in territory during active nest")nest_data_with_threat_data_7d %>%
filter(hof_p <= ceiling(as.numeric(threat_data_99_ql_$hof_p[1]))) %>%
ggplot() +
geom_histogram(aes(hof_p), binwidth = 1) +
luke_theme +
xlab("maximum hooved print level detected in territory during active nest")nest_data_with_threat_data_7d %>%
filter(fox_p <= ceiling(as.numeric(threat_data_99_ql_$fox_p[1]))) %>%
ggplot() +
geom_histogram(aes(fox_p), binwidth = 1) +
luke_theme +
xlab("maximum fox print level detected in territory during active nest")nest_data_with_threat_data_7d_ <-
nest_data_with_threat_data_7d %>%
filter(fox_p <= ceiling(as.numeric(threat_data_99_ql_$fox_p[1]))) %>%
filter(hum_a <= ceiling(as.numeric(threat_data_99_ql_$hum_a[1]))) %>%
filter(veh_a <= ceiling(as.numeric(threat_data_99_ql_$veh_a[1]))) %>%
filter(dog_a <= ceiling(as.numeric(threat_data_99_ql_$dog_a[1]))) %>%
filter(don_a <= ceiling(as.numeric(threat_data_99_ql_$don_a[1]))) %>%
filter(dof_a <= ceiling(as.numeric(threat_data_99_ql_$dof_a[1]))) %>%
filter(pbd_a <= ceiling(as.numeric(threat_data_99_ql_$pbd_a[1]))) %>%
filter(gul_a <= ceiling(as.numeric(threat_data_99_ql_$gul_a[1]))) %>%
filter(hum_m <= ceiling(as.numeric(threat_data_99_ql_$hum_m[1]))) %>%
filter(veh_m <= ceiling(as.numeric(threat_data_99_ql_$veh_m[1]))) %>%
filter(dog_m <= ceiling(as.numeric(threat_data_99_ql_$dog_m[1]))) %>%
filter(don_m <= ceiling(as.numeric(threat_data_99_ql_$don_m[1]))) %>%
filter(dof_m <= ceiling(as.numeric(threat_data_99_ql_$dof_m[1]))) %>%
filter(pbd_m <= ceiling(as.numeric(threat_data_99_ql_$pbd_m[1]))) %>%
filter(gul_m <= ceiling(as.numeric(threat_data_99_ql_$gul_m[1]))) %>%
filter(hum_p <= ceiling(as.numeric(threat_data_99_ql_$hum_p[1]))) %>%
filter(veh_p <= ceiling(as.numeric(threat_data_99_ql_$veh_p[1]))) %>%
filter(dog_p <= ceiling(as.numeric(threat_data_99_ql_$dog_p[1]))) %>%
filter(hof_p <= ceiling(as.numeric(threat_data_99_ql_$hof_p[1]))) %>%
mutate(fox_p = ifelse(is.infinite(fox_p), 0, fox_p) %>% as.factor())Number of nests
nest_data_with_threat_data_7d_ %>%
summarise(n_obs = n())# A tibble: 1 × 1
n_obs
<int>
1 1289
Number of nests at each region
nest_data_with_threat_data_7d_ %>%
group_by(region) %>%
summarise(n_obs = n())# A tibble: 3 × 2
region n_obs
<chr> <int>
1 BSC 315
2 FP 361
3 MP 613
Number of nests at each region for each year
nest_data_with_threat_data_7d_ %>%
group_by(region, season) %>%
summarise(n_obs = n()) %>%
pivot_wider(names_from = region, values_from = n_obs) %>%
mutate(season = as.numeric(as.character(season))) %>%
arrange(season)# A tibble: 15 × 4
season BSC FP MP
<dbl> <int> <int> <int>
1 200607 7 NA 12
2 200708 6 NA 14
3 200809 7 NA 4
4 200910 5 6 12
5 201011 12 19 21
6 201112 23 7 39
7 201213 14 8 46
8 201314 8 18 41
9 201415 15 20 59
10 201516 20 25 74
11 201617 40 38 88
12 201718 38 40 62
13 201819 31 53 52
14 201920 41 59 21
15 202021 48 68 68
Number of nests at each region in each management level
nest_data_with_threat_data_7d_ %>%
group_by(region, level) %>%
summarise(n_obs = n()) %>%
pivot_wider(names_from = region, values_from = n_obs) # A tibble: 5 × 4
level BSC FP MP
<fct> <int> <int> <int>
1 L0 16 75 110
2 L1 37 24 50
3 L2 67 14 66
4 L3 192 239 386
5 L4 3 9 1
Number of nests at each region in each management status
nest_data_with_threat_data_7d_ %>%
group_by(region, status) %>%
summarise(n_obs = n()) %>%
pivot_wider(names_from = region, values_from = n_obs) # A tibble: 2 × 4
status BSC FP MP
<fct> <int> <int> <int>
1 N 52 94 159
2 Y 263 267 454
occ_FP <-
nest_data_with_threat_data_7d_ %>%
filter(region == "FP") %>%
pull(LastChecked) %>%
max(., na.rm = TRUE)
occ_MP <-
nest_data_with_threat_data_7d_ %>%
filter(region == "MP") %>%
pull(LastChecked) %>%
max(., na.rm = TRUE)
occ_BSC <-
nest_data_with_threat_data_7d_ %>%
filter(region == "BSC") %>%
pull(LastChecked) %>%
max(., na.rm = TRUE)
# create processed RMARK data format as NestSurvival with Year as group
nest_data.processed_FP_5d <-
RMark::process.data(nest_data_with_threat_data_7d_ %>%
filter(region == "FP"),
model = "Nest",
nocc = occ_FP, groups = c("season",
"nest_hab",
"status",
# "site",
"level",
"fox_p"))
nest_data.processed_MP_5d <-
RMark::process.data(nest_data_with_threat_data_7d_ %>%
filter(region == "MP"),
model = "Nest",
nocc = occ_MP, groups = c("season",
"nest_hab",
"status",
# "site",
"level",
"fox_p"))
nest_data.processed_BSC_5d <-
RMark::process.data(nest_data_with_threat_data_7d_ %>%
filter(region == "BSC"),
model = "Nest",
nocc = occ_BSC, groups = c("season",
"nest_hab",
"status",
# "site",
"level",
"fox_p"))
# create the design data
nest_fate.ddl_FP_5d <- RMark::make.design.data(nest_data.processed_FP_5d)
nest_fate.ddl_MP_5d <- RMark::make.design.data(nest_data.processed_MP_5d)
nest_fate.ddl_BSC_5d <- RMark::make.design.data(nest_data.processed_BSC_5d)
# add a new variable to the design data that is the quadratic transformation of
# time
time <- c(0:(occ_FP-1))
Cubic <- time^3
Quadratic <- time^2
quad_time <- data.frame(time, Quadratic, Cubic)
quad_time$time <- c(1:occ_FP)
nest_fate.ddl_FP_5d$S <-
RMark::merge_design.covariates(nest_fate.ddl_FP_5d$S, quad_time,
bygroup = FALSE, bytime = TRUE)
time <- c(0:(occ_MP-1))
Cubic <- time^3
Quadratic <- time^2
quad_time <- data.frame(time, Quadratic, Cubic)
quad_time$time <- c(1:occ_MP)
nest_fate.ddl_MP_5d$S <-
RMark::merge_design.covariates(nest_fate.ddl_MP_5d$S, quad_time,
bygroup = FALSE, bytime = TRUE)
time <- c(0:(occ_BSC-1))
Cubic <- time^3
Quadratic <- time^2
quad_time <- data.frame(time, Quadratic, Cubic)
quad_time$time <- c(1:occ_BSC)
nest_fate.ddl_BSC_5d$S <-
RMark::merge_design.covariates(nest_fate.ddl_BSC_5d$S, quad_time,
bygroup = FALSE, bytime = TRUE)
# nest_fate.ddl$S <-
# RMark::merge_design.covariates(nest_fate.ddl$S, data.frame(management_level = c(0, 1, 2, 3, 4)),
# bygroup = FALSE, bytime = FALSE)
# nest_fate.ddl$S <-
# inner_join(nest_fate.ddl$S, int_threat_data, by = c("site", "time"))
RMark_data_FP <-
list(nest_data.processed = nest_data.processed_FP_5d,
nest_fate.ddl = nest_fate.ddl_FP_5d)
RMark_data_MP <-
list(nest_data.processed = nest_data.processed_MP_5d,
nest_fate.ddl = nest_fate.ddl_MP_5d)
RMark_data_BSC <-
list(nest_data.processed = nest_data.processed_BSC_5d,
nest_fate.ddl = nest_fate.ddl_BSC_5d)
# RMark_data_FP$nest_data.processed$data %>% summary()
# RMark_data_MP$nest_data.processed$data %>% summary()
# RMark_data_BSC$nest_data.processed$data %>% summary()### Fleurieu Peninsula model selection
nest_survival_FP <- function()
{
# Specify models to test
# constant daily survival rate (DSR)
S.dot <-
list(formula = ~1)
# fox print status
# S.fox_p <-
# list(formula = ~fox_p)
#### maximum counts of threats
# max humans detected
S.hum_m <-
list(formula = ~hum_m)
# max vehicles detected
S.veh_m <-
list(formula = ~veh_m)
# max dogs detected
S.dog_m <-
list(formula = ~dog_m)
# max dogs off leash detected
S.dof_m <-
list(formula = ~dof_m)
# max corvids detected
S.pbd_m <-
list(formula = ~pbd_m)
# max gulls detected
S.gul_m <-
list(formula = ~gul_m)
#### interaction of max threat counts and management status
# max humans detected
S.hum_m_x_status <-
list(formula = ~hum_m * status)
# max vehicles detected and management status
S.veh_m_x_status <-
list(formula = ~veh_m * status)
# max dogs detected and management status
S.dog_m_x_status <-
list(formula = ~dog_m * status)
# max dogs off leash detected and management status
S.dof_m_x_status <-
list(formula = ~dof_m * status)
# max corvids detected and management status
S.pbd_m_x_status <-
list(formula = ~pbd_m * status)
# max gulls detected and management status
S.gul_m_x_status <-
list(formula = ~gul_m * status)
# specify to run as a nest survival model in program MARK
cml <- RMark::create.model.list("Nest")
# run model list in MARK. Supress generation of MARK files.
model.list <- RMark::mark.wrapper(cml,
data = RMark_data_FP$nest_data.processed,
ddl = RMark_data_FP$nest_fate.ddl,
threads = 4,
brief = TRUE,
delete = TRUE)
# store completed model list
return(model.list)
}
nest_survival_run_FP <- nest_survival_FP()
nest_survival_run_FP
nest_survival_FP <-
list(RMark_data = RMark_data_FP,
model_selection = nest_survival_run_FP)
saveRDS(nest_survival_FP, file = "output/nest_survival_FP_threats&status.rds")### Mornington Peninsula model selection
nest_survival_MP <- function()
{
# Specify models to test
# constant daily survival rate (DSR)
S.dot <-
list(formula = ~1)
# fox print status
# S.fox_p <-
# list(formula = ~fox_p)
#### maximum counts of threats
# max humans detected
S.hum_m <-
list(formula = ~hum_m)
# max vehicles detected
# S.veh_m <-
# list(formula = ~veh_m)
# max dogs detected
S.dog_m <-
list(formula = ~dog_m)
# max dogs off leash detected
S.dof_m <-
list(formula = ~dof_m)
# max corvids detected
S.pbd_m <-
list(formula = ~pbd_m)
# max gulls detected
S.gul_m <-
list(formula = ~gul_m)
#### interaction of max threat counts and management status
# max humans detected
S.hum_m_x_status <-
list(formula = ~hum_m * status)
# max vehicles detected and management status
# S.veh_m_x_status <-
# list(formula = ~veh_m * status)
# max dogs detected and management status
S.dog_m_x_status <-
list(formula = ~dog_m * status)
# max dogs off leash detected and management status
S.dof_m_x_status <-
list(formula = ~dof_m * status)
# max corvids detected and management status
S.pbd_m_x_status <-
list(formula = ~pbd_m * status)
# max gulls detected and management status
S.gul_m_x_status <-
list(formula = ~gul_m * status)
# specify to run as a nest survival model in program MARK
cml <- RMark::create.model.list("Nest")
# run model list in MARK. Supress generation of MARK files.
model.list <- RMark::mark.wrapper(cml,
data = RMark_data_MP$nest_data.processed,
ddl = RMark_data_MP$nest_fate.ddl,
threads = 4,
brief = TRUE,
delete = TRUE)
# store completed model list
return(model.list)
}
nest_survival_run_MP <- nest_survival_MP()
nest_survival_run_MP
nest_survival_MP <-
list(RMark_data = RMark_data_MP,
model_selection = nest_survival_run_MP)
saveRDS(nest_survival_MP, file = "output/nest_survival_MP_threats&status.rds")### Bellarine / Surf Coast model selection
nest_survival_BSC <- function()
{
# Specify models to test
# constant daily survival rate (DSR)
S.dot <-
list(formula = ~1)
# fox print status
# S.fox_p <-
# list(formula = ~fox_p)
#### maximum counts of threats
# max humans detected
S.hum_m <-
list(formula = ~hum_m)
# max vehicles detected
# S.veh_m <-
# list(formula = ~veh_m)
# max dogs detected
S.dog_m <-
list(formula = ~dog_m)
# max dogs off leash detected
S.dof_m <-
list(formula = ~dof_m)
# max corvids detected
S.pbd_m <-
list(formula = ~pbd_m)
# max gulls detected
S.gul_m <-
list(formula = ~gul_m)
#### interaction of max threat counts and management status
# max humans detected
S.hum_m_x_status <-
list(formula = ~hum_m * status)
# max vehicles detected and management status
# S.veh_m_x_status <-
# list(formula = ~veh_m * status)
# max dogs detected and management status
S.dog_m_x_status <-
list(formula = ~dog_m * status)
# max dogs off leash detected and management status
S.dof_m_x_status <-
list(formula = ~dof_m * status)
# max corvids detected and management status
S.pbd_m_x_status <-
list(formula = ~pbd_m * status)
# max gulls detected and management status
S.gul_m_x_status <-
list(formula = ~gul_m * status)
# specify to run as a nest survival model in program MARK
cml <- RMark::create.model.list("Nest")
# run model list in MARK. Supress generation of MARK files.
model.list <- RMark::mark.wrapper(cml,
data = RMark_data_BSC$nest_data.processed,
ddl = RMark_data_BSC$nest_fate.ddl,
threads = 4,
brief = TRUE,
delete = TRUE)
# store completed model list
return(model.list)
}
nest_survival_run_BSC <- nest_survival_BSC()
nest_survival_run_BSC
nest_survival_BSC <-
list(RMark_data = RMark_data_BSC,
model_selection = nest_survival_run_BSC)
saveRDS(nest_survival_BSC, file = "output/nest_survival_BSC_threats&status.rds")model selection results
nest_survival_FP <- readRDS(file = "output/nest_survival_FP_threats&status.rds")
nest_survival_run_FP <- nest_survival_FP$model_selection
nest_survival_run_FP$model.table %>%
dplyr::select(model, npar, DeltaAICc, weight) %>%
gt() %>%
cols_label(model = html("<i>Fleurieu Peninsula</i>"),
npar = "K",
DeltaAICc = "DeltaAICc",
weight = "weight") %>%
fmt_number(columns = DeltaAICc,
rows = 1:10,
decimals = 2,
use_seps = FALSE) %>%
fmt_number(columns = weight,
rows = 1:10,
decimals = 3,
use_seps = FALSE) %>%
cols_align(align = "left",
columns = vars(model)) %>%
tab_options(row_group.font.weight = "bold",
row_group.background.color = brewer.pal(9,"Greys")[3],
table.font.size = 12,
data_row.padding = 3,
row_group.padding = 4,
summary_row.padding = 2,
column_labels.font.size = 14,
row_group.font.size = 12,
table.width = pct(60))| Fleurieu Peninsula | K | DeltaAICc | weight |
|---|---|---|---|
| S(~gul_m * status) | 4 | 0.00 | 0.866 |
| S(~dof_m * status) | 4 | 4.11 | 0.111 |
| S(~pbd_m * status) | 4 | 7.74 | 0.018 |
| S(~veh_m * status) | 4 | 11.36 | 0.003 |
| S(~dog_m * status) | 4 | 12.98 | 0.001 |
| S(~hum_m * status) | 4 | 13.18 | 0.001 |
| S(~pbd_m) | 2 | 40.80 | 0.000 |
| S(~1) | 1 | 51.66 | 0.000 |
| S(~dog_m) | 2 | 51.75 | 0.000 |
| S(~gul_m) | 2 | 52.88 | 0.000 |
| S(~hum_m) | 2 | 53.02848 | 2.645023e-12 |
| S(~veh_m) | 2 | 53.21098 | 2.414349e-12 |
| S(~dof_m) | 2 | 53.59728 | 1.990289e-12 |
nest_survival_MP <- readRDS(file = "output/nest_survival_MP_threats&status.rds")
nest_survival_run_MP <- nest_survival_MP$model_selection
nest_survival_run_MP$model.table %>%
dplyr::select(model, npar, DeltaAICc, weight) %>%
gt() %>%
cols_label(model = html("<i>Mornington Peninsula</i>"),
npar = "K",
DeltaAICc = "DeltaAICc",
weight = "weight") %>%
fmt_number(columns = DeltaAICc,
rows = 1:10,
decimals = 2,
use_seps = FALSE) %>%
fmt_number(columns = weight,
rows = 1:10,
decimals = 3,
use_seps = FALSE) %>%
cols_align(align = "left",
columns = vars(model)) %>%
tab_options(row_group.font.weight = "bold",
row_group.background.color = brewer.pal(9,"Greys")[3],
table.font.size = 12,
data_row.padding = 3,
row_group.padding = 4,
summary_row.padding = 2,
column_labels.font.size = 14,
row_group.font.size = 12,
table.width = pct(60))| Mornington Peninsula | K | DeltaAICc | weight |
|---|---|---|---|
| S(~pbd_m * status) | 4 | 0.00 | 0.744 |
| S(~gul_m * status) | 4 | 3.67 | 0.119 |
| S(~pbd_m) | 2 | 4.35 | 0.084 |
| S(~dof_m * status) | 4 | 7.26 | 0.020 |
| S(~hum_m * status) | 4 | 8.00 | 0.014 |
| S(~dog_m * status) | 4 | 8.39 | 0.011 |
| S(~dof_m) | 2 | 11.62 | 0.002 |
| S(~gul_m) | 2 | 11.92 | 0.002 |
| S(~1) | 1 | 12.26 | 0.002 |
| S(~dog_m) | 2 | 12.31 | 0.002 |
| S(~hum_m) | 2 | 12.75149 | 0.001266101 |
nest_survival_BSC <- readRDS(file = "output/nest_survival_BSC_threats&status.rds")
nest_survival_run_BSC <- nest_survival_BSC$model_selection
nest_survival_run_BSC$model.table %>%
dplyr::select(model, npar, DeltaAICc, weight) %>%
gt() %>%
cols_label(model = html("<i>Bellarine / Surf Coast</i>"),
npar = "K",
DeltaAICc = "DeltaAICc",
weight = "weight") %>%
fmt_number(columns = DeltaAICc,
rows = 1:10,
decimals = 2,
use_seps = FALSE) %>%
fmt_number(columns = weight,
rows = 1:10,
decimals = 3,
use_seps = FALSE) %>%
cols_align(align = "left",
columns = vars(model)) %>%
tab_options(row_group.font.weight = "bold",
row_group.background.color = brewer.pal(9,"Greys")[3],
table.font.size = 12,
data_row.padding = 3,
row_group.padding = 4,
summary_row.padding = 2,
column_labels.font.size = 14,
row_group.font.size = 12,
table.width = pct(60))| Bellarine / Surf Coast | K | DeltaAICc | weight |
|---|---|---|---|
| S(~pbd_m * status) | 4 | 0.00 | 0.562 |
| S(~hum_m * status) | 4 | 1.05 | 0.333 |
| S(~dof_m * status) | 4 | 5.14 | 0.043 |
| S(~gul_m * status) | 4 | 5.41 | 0.038 |
| S(~dog_m * status) | 4 | 6.26 | 0.025 |
| S(~pbd_m) | 2 | 35.31 | 0.000 |
| S(~1) | 1 | 36.37 | 0.000 |
| S(~gul_m) | 2 | 37.32 | 0.000 |
| S(~dof_m) | 2 | 37.67 | 0.000 |
| S(~hum_m) | 2 | 38.32 | 0.000 |
| S(~dog_m) | 2 | 38.37157 | 2.616087e-09 |
S.fundays <-
mark(data = RMark_data_FP$nest_data.processed,
ddl = RMark_data_FP$nest_fate.ddl,
model = "Nest",
model.parameters = list("S" = list(formula = ~ fundays)),
brief = TRUE,
delete = TRUE)
Model: S(~fundays) npar= 2 lnl = 1304.8575 AICc = 1308.8599
min.fundays = min(RMark_data_FP$nest_data.processed$data$fundays)
max.fundays = max(RMark_data_FP$nest_data.processed$data$fundays)
fundays.values = seq(from = min.fundays, to = max.fundays, length = 100)
pred.fundays <-
covariate.predictions(model = S.fundays,
data = data.frame(fundays = fundays.values),
indices = 1)
pred.fundays_FP <-
pred.fundays$estimates %>%
mutate(region = "FP")
S.fundays <-
mark(data = RMark_data_MP$nest_data.processed,
ddl = RMark_data_MP$nest_fate.ddl,
model = "Nest",
model.parameters = list("S" = list(formula = ~ fundays)),
brief = TRUE,
delete = TRUE)
Model: S(~fundays) npar= 2 lnl = 1980.8532 AICc = 1984.8546
min.fundays = min(RMark_data_MP$nest_data.processed$data$fundays)
max.fundays = max(RMark_data_MP$nest_data.processed$data$fundays)
fundays.values = seq(from = min.fundays, to = max.fundays, length = 100)
pred.fundays <-
covariate.predictions(model = S.fundays,
data = data.frame(fundays = fundays.values),
indices = 1)
pred.fundays_MP <-
pred.fundays$estimates %>%
mutate(region = "MP")
S.fundays <-
mark(data = RMark_data_BSC$nest_data.processed,
ddl = RMark_data_BSC$nest_fate.ddl,
model = "Nest",
model.parameters = list("S" = list(formula = ~ fundays)),
brief = TRUE,
delete = TRUE)
Model: S(~fundays) npar= 2 lnl = 1063.7211 AICc = 1067.7245
min.fundays = min(RMark_data_BSC$nest_data.processed$data$fundays)
max.fundays = max(RMark_data_BSC$nest_data.processed$data$fundays)
fundays.values = seq(from = min.fundays, to = max.fundays, length = 100)
pred.fundays <-
covariate.predictions(model = S.fundays,
data = data.frame(fundays = fundays.values),
indices = 1)
pred.fundays_BSC <-
pred.fundays$estimates %>%
mutate(region = "BSC")
pred.fundays <-
bind_rows(pred.fundays_FP, pred.fundays_MP, pred.fundays_BSC)
ggplot(pred.fundays,
aes(x = covdata, y = estimate, color = region, fill = region)) +
geom_line(size = 1.5) +
geom_ribbon(aes(ymin = lcl, ymax = ucl), alpha = 0.2) +
scale_colour_brewer(palette = "Dark2") +
scale_fill_brewer(palette = "Dark2") +
scale_x_continuous(breaks = c(0, 5, 10, 15, 20, 25)) +
luke_theme +
theme(legend.position = "none",
legend.justification = c(1, 0),
strip.background = element_blank()) +
xlab("number of weekend days and holidays exposed to") +
ylab("estimated daily survival rate (± 95% CI)") +
ylim(c(0, 1)) +
facet_grid(. ~ region, labeller = as_labeller(region_names))S.fundays_status <-
mark(data = RMark_data_FP$nest_data.processed,
ddl = RMark_data_FP$nest_fate.ddl,
model = "Nest",
model.parameters = list("S" = list(formula = ~ fundays + status)),
brief = TRUE,
delete = TRUE)
Model: S(~fundays + status) npar= 3 lnl = 1289.1298 AICc = 1295.1345
min.fundays_status = min(RMark_data_FP$nest_data.processed$data$fundays)
max.fundays_status = max(RMark_data_FP$nest_data.processed$data$fundays)
fundays.values = seq(from = min.fundays_status, to = max.fundays_status, length = 100)
pred.fundays_status <-
covariate.predictions(model = S.fundays_status,
data = data.frame(fundays = fundays.values),
indices = c(as.numeric(row.names(filter(RMark_data_FP$nest_fate.ddl$S, status == "N")[1,])),
as.numeric(row.names(filter(RMark_data_FP$nest_fate.ddl$S, status == "Y")[1,]))))
pred.fundays_status_FP <-
pred.fundays_status$estimates %>%
mutate(region = "FP",
status = ifelse(par.index == 1, "N", "Y"))
S.fundays_status <-
mark(data = RMark_data_MP$nest_data.processed,
ddl = RMark_data_MP$nest_fate.ddl,
model = "Nest",
model.parameters = list("S" = list(formula = ~ fundays + status)),
brief = TRUE,
delete = TRUE)
Model: S(~fundays + status) npar= 3 lnl = 1980.4679 AICc = 1986.4708
min.fundays_status = min(RMark_data_MP$nest_data.processed$data$fundays)
max.fundays_status = max(RMark_data_MP$nest_data.processed$data$fundays)
fundays.values = seq(from = min.fundays_status, to = max.fundays_status, length = 100)
pred.fundays_status <-
covariate.predictions(model = S.fundays_status,
data = data.frame(fundays = fundays.values),
indices = c(as.numeric(row.names(filter(RMark_data_MP$nest_fate.ddl$S, status == "N")[1,])),
as.numeric(row.names(filter(RMark_data_MP$nest_fate.ddl$S, status == "Y")[1,]))))
pred.fundays_status_MP <-
pred.fundays_status$estimates %>%
mutate(region = "MP",
status = ifelse(par.index == 1, "N", "Y"))
S.fundays_status <-
mark(data = RMark_data_BSC$nest_data.processed,
ddl = RMark_data_BSC$nest_fate.ddl,
model = "Nest",
model.parameters = list("S" = list(formula = ~ fundays + status)),
brief = TRUE,
delete = TRUE)
Model: S(~fundays + status) npar= 3 lnl = 1028.7602 AICc = 1034.7672
min.fundays_status = min(RMark_data_BSC$nest_data.processed$data$fundays)
max.fundays_status = max(RMark_data_BSC$nest_data.processed$data$fundays)
fundays.values = seq(from = min.fundays_status, to = max.fundays_status, length = 100)
pred.fundays_status <-
covariate.predictions(model = S.fundays_status,
data = data.frame(fundays = fundays.values),
indices = c(as.numeric(row.names(filter(RMark_data_BSC$nest_fate.ddl$S, status == "N")[1,])),
as.numeric(row.names(filter(RMark_data_BSC$nest_fate.ddl$S, status == "Y")[1,]))))
pred.fundays_status_BSC <-
pred.fundays_status$estimates %>%
mutate(region = "BSC",
status = ifelse(par.index == 1, "N", "Y"))
pred.fundays_status <-
bind_rows(pred.fundays_status_FP, pred.fundays_status_MP, pred.fundays_status_BSC)
ggplot(pred.fundays_status,
aes(x = covdata, y = estimate, color = status, fill = status)) +
geom_line(size = 1.5) +
geom_ribbon(aes(ymin = lcl, ymax = ucl), alpha = 0.2) +
scale_colour_brewer(palette = "Dark2",
labels = c("No management", "Management")) +
scale_fill_brewer(palette = "Dark2",
labels = c("No management", "Management")) +
scale_x_continuous(breaks = c(0, 5, 10, 15, 20, 25)) +
luke_theme +
theme(legend.position = c(0.25, 0.1),
legend.title = element_blank(),
legend.justification = c(1, 0),
strip.background = element_blank()) +
xlab("number of weekend days and holidays exposed to") +
ylab("estimated daily survival rate (± 95% CI)") +
ylim(c(0, 1)) +
facet_grid(. ~ region, labeller = as_labeller(region_names))S.levels <-
mark(data = RMark_data_FP$nest_data.processed,
ddl = RMark_data_FP$nest_fate.ddl,
model = "Nest",
model.parameters = list("S" = list(formula = ~ level)),
brief = TRUE,
delete = TRUE)
Model: S(~level) npar= 5 lnl = 1359.207 AICc = 1369.2188
nest_survival_reals_FP_levels <-
S.levels$results$real
Groups <- data.frame(
str_split_fixed(rownames(nest_survival_reals_FP_levels), " ", n = 4))
nest_survival_reals_FP_levels <- cbind(Groups, nest_survival_reals_FP_levels)
nest_survival_reals_FP_levels$rows <- rownames(nest_survival_reals_FP_levels)
nest_survival_reals_FP_levels$management_level <-
as.factor(str_sub(nest_survival_reals_FP_levels$rows,
nchar(nest_survival_reals_FP_levels$rows) - 8, nchar(nest_survival_reals_FP_levels$rows) - 7))
nest_survival_reals_FP_levels <-
nest_survival_reals_FP_levels %>%
dplyr::select(management_level, estimate, se, lcl, ucl) %>%
mutate(region = "FP")
row.names(nest_survival_reals_FP_levels) <- NULL
S.levels <-
mark(data = RMark_data_MP$nest_data.processed,
ddl = RMark_data_MP$nest_fate.ddl,
model = "Nest",
model.parameters = list("S" = list(formula = ~ level)),
brief = TRUE,
delete = TRUE)
Model: S(~level) npar= 5 lnl = 2108.7714 AICc = 2118.7786
nest_survival_reals_MP_levels <-
S.levels$results$real
Groups <- data.frame(
str_split_fixed(rownames(nest_survival_reals_MP_levels), " ", n = 4))
nest_survival_reals_MP_levels <- cbind(Groups, nest_survival_reals_MP_levels)
nest_survival_reals_MP_levels$rows <- rownames(nest_survival_reals_MP_levels)
nest_survival_reals_MP_levels$management_level <-
as.factor(str_sub(nest_survival_reals_MP_levels$rows,
nchar(nest_survival_reals_MP_levels$rows) - 8, nchar(nest_survival_reals_MP_levels$rows) - 7))
nest_survival_reals_MP_levels <-
nest_survival_reals_MP_levels %>%
dplyr::select(management_level, estimate, se, lcl, ucl) %>%
mutate(region = "MP")
row.names(nest_survival_reals_MP_levels) <- NULL
S.levels <-
mark(data = RMark_data_BSC$nest_data.processed,
ddl = RMark_data_BSC$nest_fate.ddl,
model = "Nest",
model.parameters = list("S" = list(formula = ~ level)),
brief = TRUE,
delete = TRUE)
Model: S(~level) npar= 5 lnl = 1036.1791 AICc = 1046.1965
nest_survival_reals_BSC_levels <-
S.levels$results$real
Groups <- data.frame(
str_split_fixed(rownames(nest_survival_reals_BSC_levels), " ", n = 4))
nest_survival_reals_BSC_levels <- cbind(Groups, nest_survival_reals_BSC_levels)
nest_survival_reals_BSC_levels$rows <- rownames(nest_survival_reals_BSC_levels)
nest_survival_reals_BSC_levels$management_level <-
as.factor(str_sub(nest_survival_reals_BSC_levels$rows,
nchar(nest_survival_reals_BSC_levels$rows) - 8, nchar(nest_survival_reals_BSC_levels$rows) - 7))
nest_survival_reals_BSC_levels <-
nest_survival_reals_BSC_levels %>%
dplyr::select(management_level, estimate, se, lcl, ucl) %>%
mutate(region = "BSC")
row.names(nest_survival_reals_BSC_levels) <- NULL
nest_survival_reals_levels <-
bind_rows(nest_survival_reals_FP_levels,
nest_survival_reals_MP_levels,
nest_survival_reals_BSC_levels)
ggplot() +
geom_line(data = nest_survival_reals_levels,
aes(x = management_level, y = estimate, color = region, group = region),
position = position_dodge(width = 0.5), alpha = 0.2, size = 2) +
geom_errorbar(data = nest_survival_reals_levels,
aes(ymin = lcl, ymax = ucl,
x = management_level,
y = estimate, group = region), position = position_dodge(width = 0.5),
alpha = 0.5, color = "black", width = 0.3, lwd = 0.5) +
geom_point(data = nest_survival_reals_levels,
aes(x = management_level, y = estimate, fill = region),
shape = 21, size = 4, position = position_dodge(width = 0.5)) +
scale_colour_brewer(palette = "Set1") +
luke_theme +
theme(legend.position = c(0.8, 0.2),
legend.justification = c(1, 0),
strip.background = element_blank()) +
xlab("management level") +
ylab("estimated daily survival rate (± 95% CI)") +
ylim(c(0.4, 1)) +
scale_colour_brewer(palette = "Dark2",
name = "Region",
labels = c("Bellarine/Surf Coast", "Fleurieu Peninsula", "Mornington Peninsula")) +
scale_fill_brewer(palette = "Dark2",
name = "Region",
labels = c("Bellarine/Surf Coast", "Fleurieu Peninsula", "Mornington Peninsula"))S.status <-
mark(data = RMark_data_FP$nest_data.processed,
ddl = RMark_data_FP$nest_fate.ddl,
model = "Nest",
model.parameters = list("S" = list(formula = ~ status)),
brief = TRUE,
delete = TRUE)
Model: S(~status) npar= 2 lnl = 1360.7428 AICc = 1364.7452
nest_survival_reals_FP_status <-
S.status$results$real
Groups <- data.frame(
str_split_fixed(rownames(nest_survival_reals_FP_status), " ", n = 4))
nest_survival_reals_FP_status <- cbind(Groups, nest_survival_reals_FP_status)
nest_survival_reals_FP_status$rows <- rownames(nest_survival_reals_FP_status)
nest_survival_reals_FP_status$status <-
as.factor(str_sub(nest_survival_reals_FP_status$rows,
nchar(nest_survival_reals_FP_status$rows) - 9, nchar(nest_survival_reals_FP_status$rows) - 9))
nest_survival_reals_FP_status <-
nest_survival_reals_FP_status %>%
dplyr::select(status, estimate, se, lcl, ucl) %>%
mutate(region = "FP")
row.names(nest_survival_reals_FP_status) <- NULL
S.status <-
mark(data = RMark_data_MP$nest_data.processed,
ddl = RMark_data_MP$nest_fate.ddl,
model = "Nest",
model.parameters = list("S" = list(formula = ~ status)),
brief = TRUE,
delete = TRUE)
Model: S(~status) npar= 2 lnl = 2107.9593 AICc = 2111.9608
nest_survival_reals_MP_status <-
S.status$results$real
Groups <- data.frame(
str_split_fixed(rownames(nest_survival_reals_MP_status), " ", n = 4))
nest_survival_reals_MP_status <- cbind(Groups, nest_survival_reals_MP_status)
nest_survival_reals_MP_status$rows <- rownames(nest_survival_reals_MP_status)
nest_survival_reals_MP_status$status <-
as.factor(str_sub(nest_survival_reals_MP_status$rows,
nchar(nest_survival_reals_MP_status$rows) - 9, nchar(nest_survival_reals_MP_status$rows) - 9))
nest_survival_reals_MP_status <-
nest_survival_reals_MP_status %>%
dplyr::select(status, estimate, se, lcl, ucl) %>%
mutate(region = "MP")
row.names(nest_survival_reals_MP_status) <- NULL
S.status <-
mark(data = RMark_data_BSC$nest_data.processed,
ddl = RMark_data_BSC$nest_fate.ddl,
model = "Nest",
model.parameters = list("S" = list(formula = ~ status)),
brief = TRUE,
delete = TRUE)
Model: S(~status) npar= 2 lnl = 1054.1322 AICc = 1058.1356
nest_survival_reals_BSC_status <-
S.status$results$real
Groups <- data.frame(
str_split_fixed(rownames(nest_survival_reals_BSC_status), " ", n = 4))
nest_survival_reals_BSC_status <- cbind(Groups, nest_survival_reals_BSC_status)
nest_survival_reals_BSC_status$rows <- rownames(nest_survival_reals_BSC_status)
nest_survival_reals_BSC_status$status <-
as.factor(str_sub(nest_survival_reals_BSC_status$rows,
nchar(nest_survival_reals_BSC_status$rows) - 9, nchar(nest_survival_reals_BSC_status$rows) - 9))
nest_survival_reals_BSC_status <-
nest_survival_reals_BSC_status %>%
dplyr::select(status, estimate, se, lcl, ucl) %>%
mutate(region = "BSC")
row.names(nest_survival_reals_BSC_status) <- NULL
nest_survival_reals_status <-
bind_rows(nest_survival_reals_FP_status,
nest_survival_reals_MP_status,
nest_survival_reals_BSC_status)
ggplot() +
geom_line(data = nest_survival_reals_status,
aes(x = status, y = estimate, color = region, group = region),
position = position_dodge(width = 0.5), alpha = 0.2, size = 2) +
geom_errorbar(data = nest_survival_reals_status,
aes(ymin = lcl, ymax = ucl,
x = status,
y = estimate, group = region), position = position_dodge(width = 0.5),
alpha = 0.5, color = "black", width = 0.3, lwd = 0.5) +
geom_point(data = nest_survival_reals_status,
aes(x = status, y = estimate, fill = region),
shape = 21, size = 4, position = position_dodge(width = 0.5)) +
# scale_colour_brewer(palette = "Set1") +
luke_theme +
theme(legend.position = c(0.8, 0.2),
legend.justification = c(1, 0),
strip.background = element_blank(),
axis.title.x = element_blank(),
axis.text.x = element_text(size = 10)) +
xlab("management level") +
ylab("estimated daily survival rate (± 95% CI)") +
ylim(c(0.4, 1)) +
scale_colour_brewer(palette = "Dark2",
name = "Region",
labels = c("Bellarine/Surf Coast", "Fleurieu Peninsula", "Mornington Peninsula")) +
scale_fill_brewer(palette = "Dark2",
name = "Region",
labels = c("Bellarine/Surf Coast", "Fleurieu Peninsula", "Mornington Peninsula")) +
scale_x_discrete(labels = c("No management", "management"))S.habitat <-
mark(data = RMark_data_FP$nest_data.processed,
ddl = RMark_data_FP$nest_fate.ddl,
model = "Nest",
model.parameters = list("S" = list(formula = ~ nest_hab)),
brief = TRUE,
delete = TRUE)
Model: S(~nest_hab) npar= 3 lnl = 1401.907 AICc = 1407.9117
nest_survival_reals_FP_habitat <-
S.habitat$results$real
Groups <- data.frame(
str_split_fixed(rownames(nest_survival_reals_FP_habitat), " ", n = 4))
nest_survival_reals_FP_habitat <- cbind(Groups, nest_survival_reals_FP_habitat)
nest_survival_reals_FP_habitat$habitat <- str_extract(nest_survival_reals_FP_habitat$X2, c("Beach", "Dune", "Foredune/face"))
nest_survival_reals_FP_habitat <-
nest_survival_reals_FP_habitat %>%
dplyr::select(habitat, estimate, se, lcl, ucl) %>%
mutate(region = "FP")
row.names(nest_survival_reals_FP_habitat) <- NULL
S.habitat <-
mark(data = RMark_data_MP$nest_data.processed,
ddl = RMark_data_MP$nest_fate.ddl,
model = "Nest",
model.parameters = list("S" = list(formula = ~ nest_hab)),
brief = TRUE,
delete = TRUE)
Model: S(~nest_hab) npar= 4 lnl = 2109.6131 AICc = 2117.618
nest_survival_reals_MP_habitat <-
S.habitat$results$real
Groups <- data.frame(
str_split_fixed(rownames(nest_survival_reals_MP_habitat), " ", n = 4))
nest_survival_reals_MP_habitat <- cbind(Groups, nest_survival_reals_MP_habitat)
nest_survival_reals_MP_habitat$habitat <- str_extract(nest_survival_reals_MP_habitat$X2, c("Beach", "Dune", "Foredune/face", "Rocks"))
nest_survival_reals_MP_habitat <-
nest_survival_reals_MP_habitat %>%
dplyr::select(habitat, estimate, se, lcl, ucl) %>%
mutate(region = "MP")
row.names(nest_survival_reals_MP_habitat) <- NULL
S.habitat <-
mark(data = RMark_data_BSC$nest_data.processed,
ddl = RMark_data_BSC$nest_fate.ddl,
model = "Nest",
model.parameters = list("S" = list(formula = ~ nest_hab)),
brief = TRUE,
delete = TRUE)
Model: S(~nest_hab) npar= 3 lnl = 1089.0758 AICc = 1095.0828
nest_survival_reals_BSC_habitat <-
S.habitat$results$real
Groups <- data.frame(
str_split_fixed(rownames(nest_survival_reals_BSC_habitat), " ", n = 4))
nest_survival_reals_BSC_habitat <- cbind(Groups, nest_survival_reals_BSC_habitat)
nest_survival_reals_BSC_habitat$habitat <- str_extract(nest_survival_reals_BSC_habitat$X2, c("Beach", "Dune", "Foredune/face"))
nest_survival_reals_BSC_habitat <-
nest_survival_reals_BSC_habitat %>%
dplyr::select(habitat, estimate, se, lcl, ucl) %>%
mutate(region = "BSC")
row.names(nest_survival_reals_BSC_habitat) <- NULL
nest_survival_reals_habitat <-
bind_rows(nest_survival_reals_FP_habitat,
nest_survival_reals_MP_habitat,
nest_survival_reals_BSC_habitat)
ggplot() +
geom_errorbar(data = nest_survival_reals_habitat,
aes(ymin = lcl, ymax = ucl,
x = habitat,
y = estimate, group = region), position = position_dodge(width = 0.5),
alpha = 0.5, color = "black", width = 0.3, lwd = 0.5) +
geom_point(data = nest_survival_reals_habitat,
aes(x = habitat, y = estimate, fill = region),
shape = 21, size = 4, position = position_dodge(width = 0.5)) +
# scale_colour_brewer(palette = "Set1") +
luke_theme +
theme(legend.position = c(0.5, 0.2),
legend.justification = c(1, 0),
strip.background = element_blank()) +
xlab("habitat") +
ylab("estimated daily survival rate (± 95% CI)") +
ylim(c(0.75, 1)) +
scale_colour_brewer(palette = "Dark2",
name = "Region",
labels = c("Bellarine/Surf Coast", "Fleurieu Peninsula", "Mornington Peninsula")) +
scale_fill_brewer(palette = "Dark2",
name = "Region",
labels = c("Bellarine/Surf Coast", "Fleurieu Peninsula", "Mornington Peninsula"))S.dog_m <- nest_survival_run_FP[[4]]
min.dog_m = min(RMark_data_FP$nest_data.processed$data$dog_m)
max.dog_m = max(RMark_data_FP$nest_data.processed$data$dog_m)
dog_m.values = seq(from = min.dog_m, to = max.dog_m, length = 100)
pred.dog_m_status <-
covariate.predictions(model = S.dog_m,
data = data.frame(dog_m = dog_m.values),
indices = c(as.numeric(row.names(filter(RMark_data_FP$nest_fate.ddl$S, status == "N")[1,])),
as.numeric(row.names(filter(RMark_data_FP$nest_fate.ddl$S, status == "Y")[1,]))))
pred.dog_m_status_FP <-
pred.dog_m_status$estimates %>%
mutate(region = "FP",
status = ifelse(par.index == 1, "N", "Y"))
S.dog_m <- nest_survival_run_MP[[4]]
min.dog_m = min(RMark_data_MP$nest_data.processed$data$dog_m)
max.dog_m = max(RMark_data_MP$nest_data.processed$data$dog_m)
dog_m.values = seq(from = min.dog_m, to = max.dog_m, length = 100)
pred.dog_m_status <-
covariate.predictions(model = S.dog_m,
data = data.frame(dog_m = dog_m.values),
indices = c(as.numeric(row.names(filter(RMark_data_MP$nest_fate.ddl$S, status == "N")[1,])),
as.numeric(row.names(filter(RMark_data_MP$nest_fate.ddl$S, status == "Y")[1,]))))
pred.dog_m_status_MP <-
pred.dog_m_status$estimates %>%
mutate(region = "MP",
status = ifelse(par.index == 1, "N", "Y"))
S.dog_m <- nest_survival_run_BSC[[4]]
min.dog_m = min(RMark_data_BSC$nest_data.processed$data$dog_m)
max.dog_m = max(RMark_data_BSC$nest_data.processed$data$dog_m)
dog_m.values = seq(from = min.dog_m, to = max.dog_m, length = 100)
pred.dog_m_status <-
covariate.predictions(model = S.dog_m,
data = data.frame(dog_m = dog_m.values),
indices = c(as.numeric(row.names(filter(RMark_data_BSC$nest_fate.ddl$S, status == "N")[1,])),
as.numeric(row.names(filter(RMark_data_BSC$nest_fate.ddl$S, status == "Y")[1,]))))
pred.dog_m_status_BSC <-
pred.dog_m_status$estimates %>%
mutate(region = "BSC",
status = ifelse(par.index == 1, "N", "Y"))
pred.dog_m <-
bind_rows(pred.dog_m_status_FP, pred.dog_m_status_MP, pred.dog_m_status_BSC)
ggplot(pred.dog_m,
aes(x = covdata, y = estimate, color = status, fill = status)) +
geom_line(size = 1.5) +
geom_ribbon(aes(ymin = lcl, ymax = ucl), alpha = 0.2) +
scale_colour_brewer(palette = "Dark2",
labels = c("No management", "Management")) +
scale_fill_brewer(palette = "Dark2",
labels = c("No management", "Management")) +
scale_x_continuous(breaks = c(0, 5, 10, 15, 20, 25)) +
luke_theme +
theme(legend.position = c(0.25, 0.1),
legend.title = element_blank(),
legend.justification = c(1, 0),
strip.background = element_blank()) +
xlab("maximum number of dogs exposed to") +
ylab("estimated daily survival rate (± 95% CI)") +
ylim(c(0, 1)) +
facet_grid(. ~ region, labeller = as_labeller(region_names))S.dof_m <- nest_survival_run_FP[[2]]
min.dof_m = min(RMark_data_FP$nest_data.processed$data$dof_m)
max.dof_m = max(RMark_data_FP$nest_data.processed$data$dof_m)
dof_m.values = seq(from = min.dof_m, to = max.dof_m, length = 100)
pred.dof_m_status <-
covariate.predictions(model = S.dof_m,
data = data.frame(dof_m = dof_m.values),
indices = c(as.numeric(row.names(filter(RMark_data_FP$nest_fate.ddl$S, status == "N")[1,])),
as.numeric(row.names(filter(RMark_data_FP$nest_fate.ddl$S, status == "Y")[1,]))))
pred.dof_m_status_FP <-
pred.dof_m_status$estimates %>%
mutate(region = "FP",
status = ifelse(par.index == 1, "N", "Y"))
S.dof_m <- nest_survival_run_MP[[2]]
min.dof_m = min(RMark_data_MP$nest_data.processed$data$dof_m)
max.dof_m = max(RMark_data_MP$nest_data.processed$data$dof_m)
dof_m.values = seq(from = min.dof_m, to = max.dof_m, length = 100)
pred.dof_m_status <-
covariate.predictions(model = S.dof_m,
data = data.frame(dof_m = dof_m.values),
indices = c(as.numeric(row.names(filter(RMark_data_MP$nest_fate.ddl$S, status == "N")[1,])),
as.numeric(row.names(filter(RMark_data_MP$nest_fate.ddl$S, status == "Y")[1,]))))
pred.dof_m_status_MP <-
pred.dof_m_status$estimates %>%
mutate(region = "MP",
status = ifelse(par.index == 1, "N", "Y"))
S.dof_m <- nest_survival_run_BSC[[2]]
min.dof_m = min(RMark_data_BSC$nest_data.processed$data$dof_m)
max.dof_m = max(RMark_data_BSC$nest_data.processed$data$dof_m)
dof_m.values = seq(from = min.dof_m, to = max.dof_m, length = 100)
pred.dof_m_status <-
covariate.predictions(model = S.dof_m,
data = data.frame(dof_m = dof_m.values),
indices = c(as.numeric(row.names(filter(RMark_data_BSC$nest_fate.ddl$S, status == "N")[1,])),
as.numeric(row.names(filter(RMark_data_BSC$nest_fate.ddl$S, status == "Y")[1,]))))
pred.dof_m_status_BSC <-
pred.dof_m_status$estimates %>%
mutate(region = "BSC",
status = ifelse(par.index == 1, "N", "Y"))
pred.dof_m <-
bind_rows(pred.dof_m_status_FP, pred.dof_m_status_MP, pred.dof_m_status_BSC)
ggplot(pred.dof_m,
aes(x = covdata, y = estimate, color = status, fill = status)) +
geom_line(size = 1.5) +
geom_ribbon(aes(ymin = lcl, ymax = ucl), alpha = 0.2) +
scale_colour_brewer(palette = "Dark2",
labels = c("No management", "Management")) +
scale_fill_brewer(palette = "Dark2",
labels = c("No management", "Management")) +
scale_x_continuous(breaks = c(0, 5, 10, 15, 20, 25)) +
luke_theme +
theme(legend.position = c(0.25, 0.1),
legend.title = element_blank(),
legend.justification = c(1, 0),
strip.background = element_blank()) +
xlab("maximum number of dogs off leash exposed to") +
ylab("estimated daily survival rate (± 95% CI)") +
ylim(c(0, 1)) +
facet_grid(. ~ region, labeller = as_labeller(region_names))S.hum_m <- nest_survival_run_FP[[9]]
min.hum_m = min(RMark_data_FP$nest_data.processed$data$hum_m)
max.hum_m = max(RMark_data_FP$nest_data.processed$data$hum_m)
hum_m.values = seq(from = min.hum_m, to = max.hum_m, length = 100)
pred.hum_m_status <-
covariate.predictions(model = S.hum_m,
data = data.frame(hum_m = hum_m.values),
indices = c(as.numeric(row.names(filter(RMark_data_FP$nest_fate.ddl$S, status == "N")[1,])),
as.numeric(row.names(filter(RMark_data_FP$nest_fate.ddl$S, status == "Y")[1,]))))
pred.hum_m_status_FP <-
pred.hum_m_status$estimates %>%
mutate(region = "FP",
status = ifelse(par.index == 1, "N", "Y"))
S.hum_m <- nest_survival_run_MP[[9]]
min.hum_m = min(RMark_data_MP$nest_data.processed$data$hum_m)
max.hum_m = max(RMark_data_MP$nest_data.processed$data$hum_m)
hum_m.values = seq(from = min.hum_m, to = max.hum_m, length = 100)
pred.hum_m_status <-
covariate.predictions(model = S.hum_m,
data = data.frame(hum_m = hum_m.values),
indices = c(as.numeric(row.names(filter(RMark_data_MP$nest_fate.ddl$S, status == "N")[1,])),
as.numeric(row.names(filter(RMark_data_MP$nest_fate.ddl$S, status == "Y")[1,]))))
pred.hum_m_status_MP <-
pred.hum_m_status$estimates %>%
mutate(region = "MP",
status = ifelse(par.index == 1, "N", "Y"))
S.hum_m <- nest_survival_run_BSC[[9]]
min.hum_m = min(RMark_data_BSC$nest_data.processed$data$hum_m)
max.hum_m = max(RMark_data_BSC$nest_data.processed$data$hum_m)
hum_m.values = seq(from = min.hum_m, to = max.hum_m, length = 100)
pred.hum_m_status <-
covariate.predictions(model = S.hum_m,
data = data.frame(hum_m = hum_m.values),
indices = c(as.numeric(row.names(filter(RMark_data_BSC$nest_fate.ddl$S, status == "N")[1,])),
as.numeric(row.names(filter(RMark_data_BSC$nest_fate.ddl$S, status == "Y")[1,]))))
pred.hum_m_status_BSC <-
pred.hum_m_status$estimates %>%
mutate(region = "BSC",
status = ifelse(par.index == 1, "N", "Y"))
pred.hum_m <-
bind_rows(pred.hum_m_status_FP, pred.hum_m_status_MP, pred.hum_m_status_BSC)
ggplot(pred.hum_m,
aes(x = covdata, y = estimate, color = status, fill = status)) +
geom_line(size = 1.5) +
geom_ribbon(aes(ymin = lcl, ymax = ucl), alpha = 0.2) +
scale_colour_brewer(palette = "Dark2",
labels = c("No management", "Management")) +
scale_fill_brewer(palette = "Dark2",
labels = c("No management", "Management")) +
scale_x_continuous(breaks = c(0, 10, 20, 30, 40, 50)) +
luke_theme +
theme(legend.position = c(0.25, 0.1),
legend.title = element_blank(),
legend.justification = c(1, 0),
strip.background = element_blank()) +
xlab("maximum number of humans exposed to") +
ylab("estimated daily survival rate (± 95% CI)") +
ylim(c(0, 1)) +
facet_grid(. ~ region, labeller = as_labeller(region_names))S.pbd_m <- nest_survival_run_FP[[11]]
min.pbd_m = min(RMark_data_FP$nest_data.processed$data$pbd_m)
max.pbd_m = max(RMark_data_FP$nest_data.processed$data$pbd_m)
pbd_m.values = seq(from = min.pbd_m, to = max.pbd_m, length = 100)
pred.pbd_m_status <-
covariate.predictions(model = S.pbd_m,
data = data.frame(pbd_m = pbd_m.values),
indices = c(as.numeric(row.names(filter(RMark_data_FP$nest_fate.ddl$S, status == "N")[1,])),
as.numeric(row.names(filter(RMark_data_FP$nest_fate.ddl$S, status == "Y")[1,]))))
pred.pbd_m_status_FP <-
pred.pbd_m_status$estimates %>%
mutate(region = "FP",
status = ifelse(par.index == 1, "N", "Y"))
S.pbd_m <- nest_survival_run_MP[[11]]
min.pbd_m = min(RMark_data_MP$nest_data.processed$data$pbd_m)
max.pbd_m = max(RMark_data_MP$nest_data.processed$data$pbd_m)
pbd_m.values = seq(from = min.pbd_m, to = max.pbd_m, length = 100)
pred.pbd_m_status <-
covariate.predictions(model = S.pbd_m,
data = data.frame(pbd_m = pbd_m.values),
indices = c(as.numeric(row.names(filter(RMark_data_MP$nest_fate.ddl$S, status == "N")[1,])),
as.numeric(row.names(filter(RMark_data_MP$nest_fate.ddl$S, status == "Y")[1,]))))
pred.pbd_m_status_MP <-
pred.pbd_m_status$estimates %>%
mutate(region = "MP",
status = ifelse(par.index == 1, "N", "Y"))
S.pbd_m <- nest_survival_run_BSC[[11]]
min.pbd_m = min(RMark_data_BSC$nest_data.processed$data$pbd_m)
max.pbd_m = max(RMark_data_BSC$nest_data.processed$data$pbd_m)
pbd_m.values = seq(from = min.pbd_m, to = max.pbd_m, length = 100)
pred.pbd_m_status <-
covariate.predictions(model = S.pbd_m,
data = data.frame(pbd_m = pbd_m.values),
indices = c(as.numeric(row.names(filter(RMark_data_BSC$nest_fate.ddl$S, status == "N")[1,])),
as.numeric(row.names(filter(RMark_data_BSC$nest_fate.ddl$S, status == "Y")[1,]))))
pred.pbd_m_status_BSC <-
pred.pbd_m_status$estimates %>%
mutate(region = "BSC",
status = ifelse(par.index == 1, "N", "Y"))
pred.pbd_m <-
bind_rows(pred.pbd_m_status_FP, pred.pbd_m_status_MP, pred.pbd_m_status_BSC)
ggplot(pred.pbd_m,
aes(x = covdata, y = estimate, color = status, fill = status)) +
geom_line(size = 1.5) +
geom_ribbon(aes(ymin = lcl, ymax = ucl), alpha = 0.2) +
scale_colour_brewer(palette = "Dark2",
labels = c("No management", "Management")) +
scale_fill_brewer(palette = "Dark2",
labels = c("No management", "Management")) +
scale_x_continuous(breaks = c(0, 5, 10, 15, 20, 25)) +
luke_theme +
theme(legend.position = c(0.25, 0.1),
legend.title = element_blank(),
legend.justification = c(1, 0),
strip.background = element_blank()) +
xlab("maximum number of ravens and magpies exposed to") +
ylab("estimated daily survival rate (± 95% CI)") +
ylim(c(0, 1)) +
facet_grid(. ~ region, labeller = as_labeller(region_names))S.gul_m <- nest_survival_run_FP[[7]]
min.gul_m = min(RMark_data_FP$nest_data.processed$data$gul_m)
max.gul_m = max(RMark_data_FP$nest_data.processed$data$gul_m)
gul_m.values = seq(from = min.gul_m, to = max.gul_m, length = 100)
pred.gul_m_status <-
covariate.predictions(model = S.gul_m,
data = data.frame(gul_m = gul_m.values),
indices = c(as.numeric(row.names(filter(RMark_data_FP$nest_fate.ddl$S, status == "N")[1,])),
as.numeric(row.names(filter(RMark_data_FP$nest_fate.ddl$S, status == "Y")[1,]))))
pred.gul_m_status_FP <-
pred.gul_m_status$estimates %>%
mutate(region = "FP",
status = ifelse(par.index == 1, "N", "Y"))
S.gul_m <- nest_survival_run_MP[[7]]
min.gul_m = min(RMark_data_MP$nest_data.processed$data$gul_m)
max.gul_m = max(RMark_data_MP$nest_data.processed$data$gul_m)
gul_m.values = seq(from = min.gul_m, to = max.gul_m, length = 100)
pred.gul_m_status <-
covariate.predictions(model = S.gul_m,
data = data.frame(gul_m = gul_m.values),
indices = c(as.numeric(row.names(filter(RMark_data_MP$nest_fate.ddl$S, status == "N")[1,])),
as.numeric(row.names(filter(RMark_data_MP$nest_fate.ddl$S, status == "Y")[1,]))))
pred.gul_m_status_MP <-
pred.gul_m_status$estimates %>%
mutate(region = "MP",
status = ifelse(par.index == 1, "N", "Y"))
S.gul_m <- nest_survival_run_BSC[[7]]
min.gul_m = min(RMark_data_BSC$nest_data.processed$data$gul_m)
max.gul_m = max(RMark_data_BSC$nest_data.processed$data$gul_m)
gul_m.values = seq(from = min.gul_m, to = max.gul_m, length = 100)
pred.gul_m_status <-
covariate.predictions(model = S.gul_m,
data = data.frame(gul_m = gul_m.values),
indices = c(as.numeric(row.names(filter(RMark_data_BSC$nest_fate.ddl$S, status == "N")[1,])),
as.numeric(row.names(filter(RMark_data_BSC$nest_fate.ddl$S, status == "Y")[1,]))))
pred.gul_m_status_BSC <-
pred.gul_m_status$estimates %>%
mutate(region = "BSC",
status = ifelse(par.index == 1, "N", "Y"))
pred.gul_m <-
bind_rows(pred.gul_m_status_FP, pred.gul_m_status_MP, pred.gul_m_status_BSC)
ggplot(pred.gul_m,
aes(x = covdata, y = estimate, color = status, fill = status)) +
geom_line(size = 1.5) +
geom_ribbon(aes(ymin = lcl, ymax = ucl), alpha = 0.2) +
scale_colour_brewer(palette = "Dark2",
labels = c("No management", "Management")) +
scale_fill_brewer(palette = "Dark2",
labels = c("No management", "Management")) +
scale_x_continuous(breaks = c(0, 10, 20, 30, 40, 50, 60, 70)) +
luke_theme +
theme(legend.position = c(0.25, 0.1),
legend.title = element_blank(),
legend.justification = c(1, 0),
strip.background = element_blank()) +
xlab("maximum number of gulls exposed to") +
ylab("estimated daily survival rate (± 95% CI)") +
ylim(c(0, 1)) +
facet_grid(. ~ region, labeller = as_labeller(region_names))S.fox_prints <-
mark(data = RMark_data_FP$nest_data.processed,
ddl = RMark_data_FP$nest_fate.ddl,
model = "Nest",
model.parameters = list("S" = list(formula = ~ fox_p)),
brief = TRUE,
delete = TRUE)
Model: S(~fox_p) npar= 4 lnl = 1378.3137 AICc = 1386.3216
nest_survival_reals_FP_fox_p <-
S.fox_prints$results$real
Groups <- data.frame(
str_split_fixed(rownames(nest_survival_reals_FP_fox_p), " ", n = 4))
nest_survival_reals_FP_fox_p <- cbind(Groups, nest_survival_reals_FP_fox_p)
nest_survival_reals_FP_fox_p$rows <- rownames(nest_survival_reals_FP_fox_p)
nest_survival_reals_FP_fox_p$fox_p <-
str_sub(nest_survival_reals_FP_fox_p$rows,
nchar(nest_survival_reals_FP_fox_p$rows) - 6,
nchar(nest_survival_reals_FP_fox_p$rows) - 6)
nest_survival_reals_FP_fox_p$fox_p <-
as.factor(nest_survival_reals_FP_fox_p$fox_p)
nest_survival_reals_FP_fox_p <-
nest_survival_reals_FP_fox_p %>%
dplyr::select(fox_p, estimate, se, lcl, ucl) %>%
mutate(region = "FP") %>%
slice(-1)
row.names(nest_survival_reals_FP_fox_p) <- NULL
S.fox_prints <-
mark(data = RMark_data_MP$nest_data.processed,
ddl = RMark_data_MP$nest_fate.ddl,
model = "Nest",
model.parameters = list("S" = list(formula = ~ fox_p)),
brief = TRUE,
delete = TRUE)
Model: S(~fox_p) npar= 4 lnl = 2086.3479 AICc = 2094.3528
nest_survival_reals_MP_fox_p <-
S.fox_prints$results$real
Groups <- data.frame(
str_split_fixed(rownames(nest_survival_reals_MP_fox_p), " ", n = 4))
nest_survival_reals_MP_fox_p <- cbind(Groups, nest_survival_reals_MP_fox_p)
nest_survival_reals_MP_fox_p$rows <- rownames(nest_survival_reals_MP_fox_p)
nest_survival_reals_MP_fox_p$fox_p <-
str_sub(nest_survival_reals_MP_fox_p$rows,
nchar(nest_survival_reals_MP_fox_p$rows) - 6,
nchar(nest_survival_reals_MP_fox_p$rows) - 6)
nest_survival_reals_MP_fox_p$fox_p <-
as.factor(nest_survival_reals_MP_fox_p$fox_p)
nest_survival_reals_MP_fox_p <-
nest_survival_reals_MP_fox_p %>%
dplyr::select(fox_p, estimate, se, lcl, ucl) %>%
mutate(region = "MP") %>%
slice(-1)
row.names(nest_survival_reals_MP_fox_p) <- NULL
S.fox_prints <-
mark(data = RMark_data_BSC$nest_data.processed,
ddl = RMark_data_BSC$nest_fate.ddl,
model = "Nest",
model.parameters = list("S" = list(formula = ~ fox_p)),
brief = TRUE,
delete = TRUE)
Model: S(~fox_p) npar= 3 lnl = 1552.639 AICc = 1556.6425
nest_survival_reals_BSC_fox_p <-
S.fox_prints$results$real
Groups <- data.frame(
str_split_fixed(rownames(nest_survival_reals_BSC_fox_p), " ", n = 4))
nest_survival_reals_BSC_fox_p <- cbind(Groups, nest_survival_reals_BSC_fox_p)
nest_survival_reals_BSC_fox_p$rows <- rownames(nest_survival_reals_BSC_fox_p)
nest_survival_reals_BSC_fox_p$fox_p <-
str_sub(nest_survival_reals_BSC_fox_p$rows,
nchar(nest_survival_reals_BSC_fox_p$rows) - 6,
nchar(nest_survival_reals_BSC_fox_p$rows) - 6) %>% as.factor()
nest_survival_reals_BSC_fox_p <-
nest_survival_reals_BSC_fox_p %>%
dplyr::select(fox_p, estimate, se, lcl, ucl) %>%
mutate(region = "BSC") %>%
slice(-1)
row.names(nest_survival_reals_BSC_fox_p) <- NULL
nest_survival_reals_levels <-
bind_rows(nest_survival_reals_FP_fox_p,
nest_survival_reals_MP_fox_p,
nest_survival_reals_BSC_fox_p)
ggplot() +
geom_line(data = nest_survival_reals_levels,
aes(x = fox_p, y = estimate, color = region, group = region),
position = position_dodge(width = 0.5), alpha = 0.2, size = 2) +
geom_errorbar(data = nest_survival_reals_levels,
aes(ymin = lcl, ymax = ucl,
x = fox_p,
y = estimate, group = region), position = position_dodge(width = 0.5),
alpha = 0.5, color = "black", width = 0.3, lwd = 0.5) +
geom_point(data = nest_survival_reals_levels,
aes(x = fox_p, y = estimate, fill = region),
shape = 21, size = 4, position = position_dodge(width = 0.5)) +
luke_theme +
theme(legend.position = c(0.9, 0.1),
legend.justification = c(1, 0),
strip.background = element_blank()) +
xlab("fox prints") +
ylab("estimated daily survival rate (± 95% CI)") +
ylim(c(0.55, 1)) +
scale_colour_brewer(palette = "Dark2",
name = "Region",
labels = c("Bellarine/Surf Coast", "Fleurieu Peninsula", "Mornington Peninsula")) +
scale_fill_brewer(palette = "Dark2",
name = "Region",
labels = c("Bellarine/Surf Coast", "Fleurieu Peninsula", "Mornington Peninsula"))S.veh_m <- nest_survival_run_FP[[12]]
min.veh_m = min(RMark_data_FP$nest_data.processed$data$veh_m)
max.veh_m = max(RMark_data_FP$nest_data.processed$data$veh_m)
veh_m.values = seq(from = min.veh_m, to = max.veh_m, length = 100)
pred.veh_m_status <-
covariate.predictions(model = S.veh_m,
data = data.frame(veh_m = veh_m.values),
indices = c(as.numeric(row.names(filter(RMark_data_FP$nest_fate.ddl$S, status == "N")[1,]))))
pred.veh_m_status_FP <-
pred.veh_m_status$estimates %>%
mutate(region = "FP")
# S.veh_m <- nest_survival_run_MP[[13]]
# min.veh_m = min(RMark_data_MP$nest_data.processed$data$veh_m)
# max.veh_m = max(RMark_data_MP$nest_data.processed$data$veh_m)
# veh_m.values = seq(from = min.veh_m, to = max.veh_m, length = 100)
# pred.veh_m_status <-
# covariate.predictions(model = S.veh_m,
# data = data.frame(veh_m = veh_m.values),
# indices = c(as.numeric(row.names(filter(RMark_data_MP$nest_fate.ddl$S, status == "N")[1,]))))
# pred.veh_m_status_MP <-
# pred.veh_m_status$estimates %>%
# mutate(region = "MP")
#
# S.veh_m <- nest_survival_run_BSC[[13]]
# min.veh_m = min(RMark_data_BSC$nest_data.processed$data$veh_m)
# max.veh_m = max(RMark_data_BSC$nest_data.processed$data$veh_m)
# veh_m.values = seq(from = min.veh_m, to = max.veh_m, length = 100)
# pred.veh_m_status <-
# covariate.predictions(model = S.veh_m,
# data = data.frame(veh_m = veh_m.values),
# indices = c(as.numeric(row.names(filter(RMark_data_BSC$nest_fate.ddl$S, status == "N")[1,]))))
# pred.veh_m_status_BSC <-
# pred.veh_m_status$estimates %>%
# mutate(region = "BSC")
#
# pred.veh_m <-
# bind_rows(pred.veh_m_status_FP, pred.veh_m_status_MP, pred.veh_m_status_BSC)
ggplot(pred.veh_m_status_FP,
aes(x = covdata, y = estimate)) +
geom_line(size = 1.5) +
geom_ribbon(aes(ymin = lcl, ymax = ucl), alpha = 0.2) +
scale_colour_brewer(palette = "Dark2",
labels = c("No management", "Management")) +
scale_fill_brewer(palette = "Dark2",
labels = c("No management", "Management")) +
scale_x_continuous(breaks = c(0, 1, 2, 3, 4, 5)) +
luke_theme +
theme(legend.position = c(0.25, 0.1),
legend.title = element_blank(),
legend.justification = c(1, 0),
strip.background = element_blank()) +
xlab("maximum number of vehicles exposed to") +
ylab("estimated daily survival rate (± 95% CI)") +
ylim(c(0, 1)) +
facet_grid(. ~ region, labeller = as_labeller(region_names))S.year <-
mark(data = RMark_data_FP$nest_data.processed,
ddl = RMark_data_FP$nest_fate.ddl,
model = "Nest",
model.parameters = list("S" = list(formula = ~ season)),
brief = TRUE,
delete = TRUE)
Model: S(~season) npar= 12 lnl = 1389.0983 AICc = 1413.1598
nest_survival_reals_FP_year <-
S.year$results$real
Groups <- data.frame(
str_split_fixed(rownames(nest_survival_reals_FP_year), " ", n = 4))
nest_survival_reals_FP_year <- cbind(Groups, nest_survival_reals_FP_year)
nest_survival_reals_FP_year$season <-
as.numeric(str_sub(nest_survival_reals_FP_year$X2, 2, 5))
nest_survival_reals_FP_year$season <- paste(nest_survival_reals_FP_year$season, nest_survival_reals_FP_year$season + 1, sep = " - ")
nest_survival_reals_FP_year <-
nest_survival_reals_FP_year %>%
dplyr::select(season, estimate, se, lcl, ucl) %>%
mutate(region = "FP")
row.names(nest_survival_reals_FP_year) <- NULL
S.year <-
mark(data = RMark_data_MP$nest_data.processed,
ddl = RMark_data_MP$nest_fate.ddl,
model = "Nest",
model.parameters = list("S" = list(formula = ~ season)),
brief = TRUE,
delete = TRUE)
Model: S(~season) npar= 15 lnl = 2106.0397 AICc = 2136.0981
nest_survival_reals_MP_year <-
S.year$results$real
Groups <- data.frame(
str_split_fixed(rownames(nest_survival_reals_MP_year), " ", n = 4))
nest_survival_reals_MP_year <- cbind(Groups, nest_survival_reals_MP_year)
nest_survival_reals_MP_year$season <-
as.numeric(str_sub(nest_survival_reals_MP_year$X2, 2, 5))
nest_survival_reals_MP_year$season <- paste(nest_survival_reals_MP_year$season, nest_survival_reals_MP_year$season + 1, sep = " - ")
nest_survival_reals_MP_year <-
nest_survival_reals_MP_year %>%
dplyr::select(season, estimate, se, lcl, ucl) %>%
mutate(region = "MP")
row.names(nest_survival_reals_MP_year) <- NULL
S.year <-
mark(data = RMark_data_BSC$nest_data.processed,
ddl = RMark_data_BSC$nest_fate.ddl,
model = "Nest",
model.parameters = list("S" = list(formula = ~ season)),
brief = TRUE,
delete = TRUE)
Model: S(~season) npar= 15 lnl = 1062.2529 AICc = 1092.3926
nest_survival_reals_BSC_year <-
S.year$results$real
Groups <- data.frame(
str_split_fixed(rownames(nest_survival_reals_BSC_year), " ", n = 4))
nest_survival_reals_BSC_year <- cbind(Groups, nest_survival_reals_BSC_year)
nest_survival_reals_BSC_year$season <-
as.numeric(str_sub(nest_survival_reals_BSC_year$X2, 2, 5))
nest_survival_reals_BSC_year$season <- paste(nest_survival_reals_BSC_year$season, nest_survival_reals_BSC_year$season + 1, sep = " - ")
nest_survival_reals_BSC_year <-
nest_survival_reals_BSC_year %>%
dplyr::select(season, estimate, se, lcl, ucl) %>%
mutate(region = "BSC")
row.names(nest_survival_reals_BSC_year) <- NULL
nest_survival_reals_year <-
bind_rows(nest_survival_reals_FP_year,
nest_survival_reals_MP_year,
nest_survival_reals_BSC_year)
ggplot() +
geom_line(data = nest_survival_reals_year,
aes(x = season, y = estimate, color = region, group = region),
position = position_dodge(width = 0.5), alpha = 0.2) +
geom_errorbar(data = nest_survival_reals_year,
aes(ymin = lcl, ymax = ucl,
x = season,
y = estimate, group = region), position = position_dodge(width = 0.5),
alpha = 0.5, color = "black", width = 0.3, lwd = 0.5) +
geom_point(data = nest_survival_reals_year,
aes(x = season, y = estimate, fill = region),
shape = 21, size = 4, position = position_dodge(width = 0.5)) +
scale_colour_brewer(palette = "Set1") +
luke_theme +
theme(legend.position = "none",
legend.justification = c(1, 0),
strip.background = element_blank(),
axis.text.x = element_text(angle = 45, hjust = 1, vjust = 1)) +
xlab("season") +
ylab("estimated daily survival rate (± 95% CI)") +
ylim(c(0.7, 1)) +
scale_colour_brewer(palette = "Dark2") +
scale_fill_brewer(palette = "Dark2") +
facet_grid(region ~ ., labeller = as_labeller(region_names))# Extract estimates of survival from Cubic model with management
# (non-linear season variation and management effect)
S.season <-
mark(data = RMark_data_MP$nest_data.processed,
ddl = RMark_data_MP$nest_fate.ddl,
model = "Nest",
model.parameters = list("S" = list(formula = ~ Time + Quadratic + Cubic)),
brief = TRUE,
delete = TRUE)
Model: S(~Time + Quadratic + Cubic) npar= 4 lnl = 2112.653 AICc = 2120.6578
nest_survival_reals_MP_season <-
S.season$results$real
Groups <- data.frame(
str_split_fixed(rownames(nest_survival_reals_MP_season), " ", n = 4))
nest_survival_reals_MP_season <- cbind(Groups, nest_survival_reals_MP_season)
nest_survival_reals_MP_season$day_of_season <-
unlist(str_extract_all(nest_survival_reals_MP_season$X4, "\\d+")) %>% unique() %>% as.numeric()
nest_survival_reals_MP_season$region = "MP"
S.season <-
mark(data = RMark_data_BSC$nest_data.processed,
ddl = RMark_data_BSC$nest_fate.ddl,
model = "Nest",
model.parameters = list("S" = list(formula = ~ Time + Quadratic + Cubic)),
brief = TRUE,
delete = TRUE)
Model: S(~Time + Quadratic + Cubic) npar= 4 lnl = 1069.5321 AICc = 1077.5437
nest_survival_reals_BSC_season <-
S.season$results$real
Groups <- data.frame(
str_split_fixed(rownames(nest_survival_reals_BSC_season), " ", n = 4))
nest_survival_reals_BSC_season <- cbind(Groups, nest_survival_reals_BSC_season)
nest_survival_reals_BSC_season$day_of_season <-
unlist(str_extract_all(nest_survival_reals_BSC_season$X4, "\\d+")) %>% unique() %>% as.numeric()
nest_survival_reals_BSC_season$region = "BSC"
S.season <-
mark(data = RMark_data_FP$nest_data.processed,
ddl = RMark_data_FP$nest_fate.ddl,
model = "Nest",
model.parameters = list("S" = list(formula = ~ Time + Quadratic + Cubic)),
brief = TRUE,
delete = TRUE)
Model: S(~Time + Quadratic + Cubic) npar= 4 lnl = 1400.4724 AICc = 1408.4803
nest_survival_reals_FP_season <-
S.season$results$real
Groups <- data.frame(
str_split_fixed(rownames(nest_survival_reals_FP_season), " ", n = 4))
nest_survival_reals_FP_season <- cbind(Groups, nest_survival_reals_FP_season)
nest_survival_reals_FP_season$day_of_season <-
unlist(str_extract_all(nest_survival_reals_FP_season$X4, "\\d+")) %>% unique() %>% as.numeric()
nest_survival_reals_FP_season$region = "FP"
nest_survival_reals_season <-
bind_rows(nest_survival_reals_MP_season, nest_survival_reals_BSC_season, nest_survival_reals_FP_season) %>%
dplyr::select(region, day_of_season, estimate, lcl, ucl)
row.names(nest_survival_reals_season) <- NULL
# FP
dates_for_plot_FP <-
data.frame(date = as.Date(min(as.numeric(RMark_data_FP$nest_data.processed$data$FirstFound)):
max(max(as.numeric(RMark_data_FP$nest_data.processed$data$LastChecked)),
max(as.numeric(RMark_data_FP$nest_data.processed$data$LastPresent))),
origin = "2023-01-01") - 180,
day_of_season = c(0:(max(max(as.numeric(RMark_data_FP$nest_data.processed$data$LastChecked)),
max(as.numeric(RMark_data_FP$nest_data.processed$data$LastPresent))) -
min(as.numeric(RMark_data_FP$nest_data.processed$data$FirstFound)))))
nest_survival_reals_dates_FP <-
left_join(nest_survival_reals_FP_season, dates_for_plot_FP, by = "day_of_season")
nest_survival_season_plot_FP <-
ggplot(data = nest_survival_reals_dates_FP) +
geom_ribbon(aes(x = date, ymin = lcl, ymax = ucl),
fill = brewer.pal(8, "Dark2")[c(1)],
alpha = 0.3) +
geom_line(aes(x = date, y = estimate),
color = brewer.pal(8, "Dark2")[c(1)],
size = 1) +
scale_x_date(date_labels = "%B",
expand = c(0.01, 0.01),
date_breaks = "1 months") +
ylab("daily nest survival ± 95% CI") +
scale_y_continuous(limits = c(0, 1)) +
luke_theme +
theme(legend.position = "bottom",
legend.title = element_blank(),
panel.grid.major = element_line(colour = "grey70",
size = 0.15),
axis.title.x = element_blank(),
axis.text.x = element_text(angle = 45,
hjust = 1,
vjust = 1))
nest_discovery_season_plot_FP <-
ggplot(RMark_data_FP$nest_data.processed$data,
aes(as.Date(FirstFound, origin = "2023-01-01") - 180,
fill = Fate)) +
geom_histogram(bins = 30,
# fill = brewer.pal(8, "Set1")[c(2)],
alpha = 0.5) +
scale_fill_manual(values = brewer.pal(8, "Set1")[c(2, 1)],
labels = c("Failed", "Hatched")) +
ylab("nests found\nweekly") +
scale_x_date(date_labels = "%B",
expand = c(0.01, 0.01),
date_breaks = "1 months", limits = c(min(nest_survival_reals_dates_FP$date, na.rm = TRUE),
max(nest_survival_reals_dates_FP$date, na.rm = TRUE))) +
scale_y_continuous(breaks = c(10, 20, 30, 40)) +
luke_theme +
theme(legend.position = "none",
panel.grid.major = element_line(colour = "grey70",
size = 0.15),
axis.title.x = element_blank(),
axis.text.x = element_blank(),
axis.ticks.x = element_blank())
# merge plots together
hooded_plover_nest_plot_FP <-
nest_discovery_season_plot_FP /
nest_survival_season_plot_FP +
plot_layout(widths = c(5),
heights = unit(c(1, 3), c('in', 'in'))) +
plot_annotation(tag_levels = 'A', title = "Fleurieu Peninsula")
### MP ----
dates_for_plot_MP <-
data.frame(date = as.Date(min(as.numeric(RMark_data_MP$nest_data.processed$data$FirstFound)):
max(max(as.numeric(RMark_data_MP$nest_data.processed$data$LastChecked)),
max(as.numeric(RMark_data_MP$nest_data.processed$data$LastPresent))),
origin = "2023-01-01") - 180,
day_of_season = c(0:(max(max(as.numeric(RMark_data_MP$nest_data.processed$data$LastChecked)),
max(as.numeric(RMark_data_MP$nest_data.processed$data$LastPresent))) -
min(as.numeric(RMark_data_MP$nest_data.processed$data$FirstFound)))))
nest_survival_reals_dates_MP <-
left_join(nest_survival_reals_MP_season, dates_for_plot_MP, by = "day_of_season")
nest_survival_season_plot_MP <-
ggplot(data = nest_survival_reals_dates_MP) +
geom_ribbon(aes(x = date, ymin = lcl, ymax = ucl),
fill = brewer.pal(8, "Dark2")[c(1)],
alpha = 0.3) +
geom_line(aes(x = date, y = estimate),
color = brewer.pal(8, "Dark2")[c(1)],
size = 1) +
scale_x_date(date_labels = "%B",
expand = c(0.01, 0.01),
date_breaks = "1 months") +
ylab("daily nest survival ± 95% CI") +
scale_y_continuous(limits = c(0, 1)) +
luke_theme +
theme(legend.position = "bottom",
legend.title = element_blank(),
panel.grid.major = element_line(colour = "grey70",
size = 0.15),
axis.title.x = element_blank(),
axis.text.x = element_text(angle = 45,
hjust = 1,
vjust = 1))
nest_discovery_season_plot_MP <-
ggplot(RMark_data_MP$nest_data.processed$data,
aes(as.Date(FirstFound, origin = "2023-01-01") - 180,
fill = Fate)) +
geom_histogram(bins = 30,
# fill = brewer.pal(8, "Set1")[c(2)],
alpha = 0.5) +
scale_fill_manual(values = brewer.pal(8, "Set1")[c(2, 1)],
labels = c("Failed", "Hatched")) +
ylab("nests found\nweekly") +
scale_x_date(date_labels = "%B",
expand = c(0.01, 0.01),
date_breaks = "1 months", limits = c(min(nest_survival_reals_dates_MP$date, na.rm = TRUE),
max(nest_survival_reals_dates_MP$date, na.rm = TRUE))) +
scale_y_continuous(breaks = c(10, 20, 30, 40)) +
luke_theme +
theme(legend.position = "none",
panel.grid.major = element_line(colour = "grey70",
size = 0.15),
axis.title.x = element_blank(),
axis.text.x = element_blank(),
axis.ticks.x = element_blank())
# merge plots together
hooded_plover_nest_plot_MP <-
nest_discovery_season_plot_MP /
nest_survival_season_plot_MP +
plot_layout(widths = c(5),
heights = unit(c(1, 3), c('in', 'in'))) +
plot_annotation(tag_levels = 'A', title = "Mornington Peninsula")
### BSC ----
dates_for_plot_BSC <-
data.frame(date = as.Date(min(as.numeric(RMark_data_BSC$nest_data.processed$data$FirstFound)):
max(max(as.numeric(RMark_data_BSC$nest_data.processed$data$LastChecked)),
max(as.numeric(RMark_data_BSC$nest_data.processed$data$LastPresent))),
origin = "2023-01-01") - 180,
day_of_season = c(0:(max(max(as.numeric(RMark_data_BSC$nest_data.processed$data$LastChecked)),
max(as.numeric(RMark_data_BSC$nest_data.processed$data$LastPresent))) -
min(as.numeric(RMark_data_BSC$nest_data.processed$data$FirstFound)))))
nest_survival_reals_dates_BSC <-
left_join(nest_survival_reals_BSC_season, dates_for_plot_BSC, by = "day_of_season")
nest_survival_season_plot_BSC <-
ggplot(data = nest_survival_reals_dates_BSC) +
geom_ribbon(aes(x = date, ymin = lcl, ymax = ucl),
fill = brewer.pal(8, "Dark2")[c(1)],
alpha = 0.3) +
geom_line(aes(x = date, y = estimate),
color = brewer.pal(8, "Dark2")[c(1)],
size = 1) +
scale_x_date(date_labels = "%B",
expand = c(0.01, 0.01),
date_breaks = "1 months") +
ylab("daily nest survival ± 95% CI") +
scale_y_continuous(limits = c(0, 1)) +
luke_theme +
theme(legend.position = "bottom",
legend.title = element_blank(),
panel.grid.major = element_line(colour = "grey70",
size = 0.15),
axis.title.x = element_blank(),
axis.text.x = element_text(angle = 45,
hjust = 1,
vjust = 1))
nest_discovery_season_plot_BSC <-
ggplot(RMark_data_BSC$nest_data.processed$data,
aes(as.Date(FirstFound, origin = "2023-01-01") - 180,
fill = Fate)) +
geom_histogram(bins = 30,
# fill = brewer.pal(8, "Set1")[c(2)],
alpha = 0.5) +
scale_fill_manual(values = brewer.pal(8, "Set1")[c(2, 1)],
labels = c("Failed", "Hatched")) +
ylab("nests found\nweekly") +
scale_x_date(date_labels = "%B",
expand = c(0.01, 0.01),
date_breaks = "1 months", limits = c(min(nest_survival_reals_dates_BSC$date, na.rm = TRUE),
max(nest_survival_reals_dates_BSC$date, na.rm = TRUE))) +
scale_y_continuous(breaks = c(10, 20, 30, 40)) +
luke_theme +
theme(legend.position = "none",
panel.grid.major = element_line(colour = "grey70",
size = 0.15),
axis.title.x = element_blank(),
axis.text.x = element_blank(),
axis.ticks.x = element_blank())
# merge plots together
hooded_plover_nest_plot_BSC <-
nest_discovery_season_plot_BSC /
nest_survival_season_plot_BSC +
plot_layout(widths = c(5),
heights = unit(c(1, 3), c('in', 'in'))) +
plot_annotation(tag_levels = 'A', title = "Bellarine / Surf Coast")
hooded_plover_nest_plot_FPhooded_plover_nest_plot_MPhooded_plover_nest_plot_BSCWe can see in our model selection of nest survival all three sites that our variable “fun days” (a measure of the number of weekends or holidays a nest is exposed to) was the best at explaining variation in daily nest survival. To interpret this effect, it essentially means that if a nest is initiated on, for example, a Friday right before a long period of consecutive holidays, this nest is expected to have extremely low survival compared to a nest initiated on, for example, a Monday at the early or late part of the season when there are no holidays.
Despite “fun days” having such a strong relationship to daily nest survival, our threat variables (e.g., maximum number of dogs off leash counted, maximum number of humans counted, etc.) all showed little relationship with daily nest survival, which we interpret as a methodological effect: the surveys conducted to quantify specific threats were too infrequent to capture a meaningful measure of the pressure that these threats have on nest survival. To link “Fun days” to the threats, we here do an exploratory relationship between fundays and the threats.
library(lme4)
library(gtsummary)
library(ggeffects)
library(effects)
threat_data__scaled_FP <-
threat_data__ %>%
mutate(no_fun = ifelse(funday == 0, 1, 0),
fun = ifelse(funday == 1, 1, 0)) %>%
filter(region == "FP") %>%
mutate(humans_s = scale(humans_),
dogs_s = scale(dogs_),
pred_birds_s = scale(pred_birds_),
gull_s = scale(gulls_),
dogs_off_s = scale(dogs_off_),
obs_date2_s = scale(obs_date2))
threat_data__scaled_MP <-
threat_data__ %>%
mutate(no_fun = ifelse(funday == 0, 1, 0),
fun = ifelse(funday == 1, 1, 0)) %>%
filter(region == "MP") %>%
mutate(humans_s = scale(humans_),
dogs_s = scale(dogs_),
pred_birds_s = scale(pred_birds_),
gull_s = scale(gulls_),
dogs_off_s = scale(dogs_off_),
obs_date2_s = scale(obs_date2))
threat_data__scaled_BSC <-
threat_data__ %>%
mutate(no_fun = ifelse(funday == 0, 1, 0),
fun = ifelse(funday == 1, 1, 0)) %>%
filter(region == "BSC") %>%
mutate(humans_s = scale(humans_),
dogs_s = scale(dogs_),
pred_birds_s = scale(pred_birds_),
gull_s = scale(gulls_),
dogs_off_s = scale(dogs_off_),
obs_date2_s = scale(obs_date2))strong relationship between the number of humans detected and the occurrence of a weekend or a holiday at all 3 regions
humans_fun_day_FP_ <-
glmer(humans_ ~
poly(obs_date2, 3) +
funday + (1 | season) + (1 | site),
data = threat_data__scaled_FP,
family = "poisson")
humans_fun_day_MP_ <-
glmer(humans_ ~
poly(obs_date2, 3) +
funday + (1 | season) + (1 | site),
data = threat_data__scaled_MP,
family = "poisson")
humans_fun_day_BSC_ <-
glmer(humans_ ~
poly(obs_date2, 3) +
funday + (1 | season) + (1 | site),
data = threat_data__scaled_BSC,
family = "poisson")Fleurieu Peninsula
tbl_regression(humans_fun_day_FP_, intercept = TRUE,
label = list(obs_date2 ~ "Date", funday ~ "Weekends & Holidays"))| Characteristic | log(IRR)1 | 95% CI1 | p-value |
|---|---|---|---|
| (Intercept) | 0.40 | 0.04, 0.77 | 0.030 |
| Date | |||
| Date | 8.7 | 7.7, 9.6 | <0.001 |
| Date² | -12 | -13, -11 | <0.001 |
| Date³ | -12 | -13, -11 | <0.001 |
| Weekends & Holidays | 0.57 | 0.55, 0.58 | <0.001 |
| 1 IRR = Incidence Rate Ratio, CI = Confidence Interval | |||
Mornington Peninsula
tbl_regression(humans_fun_day_MP_, intercept = TRUE,
label = list(obs_date2 ~ "Date", funday ~ "Weekends & Holidays"))| Characteristic | log(IRR)1 | 95% CI1 | p-value |
|---|---|---|---|
| (Intercept) | 0.21 | -0.13, 0.56 | 0.2 |
| Date | |||
| Date | 17 | 16, 19 | <0.001 |
| Date² | -26 | -27, -24 | <0.001 |
| Date³ | -1.3 | -3.0, 0.36 | 0.12 |
| Weekends & Holidays | 0.68 | 0.66, 0.70 | <0.001 |
| 1 IRR = Incidence Rate Ratio, CI = Confidence Interval | |||
Bellarine / Surf Coast
tbl_regression(humans_fun_day_BSC_, intercept = TRUE,
label = list(obs_date2 ~ "Date", funday ~ "Weekends & Holidays"))| Characteristic | log(IRR)1 | 95% CI1 | p-value |
|---|---|---|---|
| (Intercept) | 0.58 | 0.26, 0.91 | <0.001 |
| Date | |||
| Date | 14 | 13, 16 | <0.001 |
| Date² | -7.0 | -8.5, -5.6 | <0.001 |
| Date³ | -13 | -14, -12 | <0.001 |
| Weekends & Holidays | 0.80 | 0.77, 0.82 | <0.001 |
| 1 IRR = Incidence Rate Ratio, CI = Confidence Interval | |||
humans_fun_day_FP__fits <-
as.data.frame(effect(term = "funday", mod = humans_fun_day_FP_,
xlevels = list(funday = seq(min(threat_data__scaled_FP[, "funday"], na.rm = TRUE), max(threat_data__scaled_FP[, "funday"], na.rm = TRUE), 1)))) %>%
mutate(region = "FP")
humans_fun_day_MP__fits <-
as.data.frame(effect(term = "funday", mod = humans_fun_day_MP_,
xlevels = list(funday = seq(min(threat_data__scaled_MP[, "funday"], na.rm = TRUE), max(threat_data__scaled_MP[, "funday"], na.rm = TRUE), 1)))) %>%
mutate(region = "MP")
humans_fun_day_BSC__fits <-
as.data.frame(effect(term = "funday", mod = humans_fun_day_BSC_,
xlevels = list(funday = seq(min(threat_data__scaled_BSC[, "funday"], na.rm = TRUE), max(threat_data__scaled_BSC[, "funday"], na.rm = TRUE), 1)))) %>%
mutate(region = "BSC")
humans_fun_day__fits <-
bind_rows(humans_fun_day_FP__fits,
humans_fun_day_MP__fits,
humans_fun_day_BSC__fits) %>%
mutate(funday = ifelse(funday == 0, "no", "yes"))
row.names(humans_fun_day__fits) <- NULL
ggplot() +
geom_line(data = humans_fun_day__fits,
aes(x = funday, y = fit, color = region, group = region),
position = position_dodge(width = 0.5), alpha = 0.2, size = 2) +
geom_errorbar(data = humans_fun_day__fits,
aes(ymin = lower, ymax = upper,
x = funday,
y = fit, group = region), position = position_dodge(width = 0.5),
alpha = 0.5, color = "black", width = 0.3, lwd = 0.5) +
geom_point(data = humans_fun_day__fits,
aes(x = funday, y = fit, fill = region),
shape = 21, size = 4, position = position_dodge(width = 0.5)) +
luke_theme +
theme(legend.position = "top",
legend.justification = c(1, 0),
strip.background = element_blank(),
axis.title.x = element_blank(),
axis.text.x = element_text(size = 10)) +
ylab("number of humans detected (± 95% CI)") +
scale_colour_brewer(palette = "Dark2",
name = "Region",
labels = c("Bellarine/Surf Coast", "Fleurieu Peninsula", "Mornington Peninsula")) +
scale_fill_brewer(palette = "Dark2",
name = "Region",
labels = c("Bellarine/Surf Coast", "Fleurieu Peninsula", "Mornington Peninsula")) +
scale_x_discrete(labels = c("weekday", "weekend/holiday"))strong relationship between the number of dogs detected and the occurrence of a weekend or a holiday at all 3 regions
dogs_fun_day_FP_ <-
glmer(dogs_ ~
poly(obs_date2, 3) +
funday + (1 | season) + (1 | site),
data = threat_data__scaled_FP,
family = "poisson")
dogs_fun_day_MP_ <-
glmer(dogs_ ~
poly(obs_date2, 3) +
funday + (1 | season) + (1 | site),
data = threat_data__scaled_MP,
family = "poisson")
dogs_fun_day_BSC_ <-
glmer(dogs_ ~
poly(obs_date2, 3) +
funday + (1 | season) + (1 | site),
data = threat_data__scaled_BSC,
family = "poisson")Fleurieu Peninsula
tbl_regression(dogs_fun_day_FP_, intercept = TRUE,
label = list(obs_date2 ~ "Date", funday ~ "Weekends & Holidays"))| Characteristic | log(IRR)1 | 95% CI1 | p-value |
|---|---|---|---|
| (Intercept) | -1.3 | -1.9, -0.82 | <0.001 |
| Date | |||
| Date | 2.5 | 0.96, 4.1 | 0.002 |
| Date² | -8.7 | -10, -7.0 | <0.001 |
| Date³ | -9.5 | -11, -7.9 | <0.001 |
| Weekends & Holidays | 0.31 | 0.28, 0.33 | <0.001 |
| 1 IRR = Incidence Rate Ratio, CI = Confidence Interval | |||
Mornington Peninsula
tbl_regression(dogs_fun_day_MP_, intercept = TRUE,
label = list(obs_date2 ~ "Date", funday ~ "Weekends & Holidays"))| Characteristic | log(IRR)1 | 95% CI1 | p-value |
|---|---|---|---|
| (Intercept) | -3.0 | -3.5, -2.4 | <0.001 |
| Date | |||
| Date | -3.0 | -9.0, 3.0 | 0.3 |
| Date² | -11 | -17, -4.1 | 0.001 |
| Date³ | -5.9 | -12, 0.22 | 0.059 |
| Weekends & Holidays | 0.58 | 0.50, 0.67 | <0.001 |
| 1 IRR = Incidence Rate Ratio, CI = Confidence Interval | |||
Bellarine / Surf Coast
tbl_regression(dogs_fun_day_BSC_, intercept = TRUE,
label = list(obs_date2 ~ "Date", funday ~ "Weekends & Holidays"))| Characteristic | log(IRR)1 | 95% CI1 | p-value |
|---|---|---|---|
| (Intercept) | -0.37 | -0.72, -0.01 | 0.041 |
| Date | |||
| Date | 3.7 | 1.4, 6.0 | 0.002 |
| Date² | 3.1 | 0.68, 5.4 | 0.012 |
| Date³ | -5.0 | -7.3, -2.7 | <0.001 |
| Weekends & Holidays | 0.60 | 0.55, 0.65 | <0.001 |
| 1 IRR = Incidence Rate Ratio, CI = Confidence Interval | |||
dogs_fun_day_FP__fits <-
as.data.frame(effect(term = "funday", mod = dogs_fun_day_FP_,
xlevels = list(funday = seq(min(threat_data__scaled_FP[, "funday"], na.rm = TRUE), max(threat_data__scaled_FP[, "funday"], na.rm = TRUE), 1)))) %>%
mutate(region = "FP")
dogs_fun_day_MP__fits <-
as.data.frame(effect(term = "funday", mod = dogs_fun_day_MP_,
xlevels = list(funday = seq(min(threat_data__scaled_MP[, "funday"], na.rm = TRUE), max(threat_data__scaled_MP[, "funday"], na.rm = TRUE), 1)))) %>%
mutate(region = "MP")
dogs_fun_day_BSC__fits <-
as.data.frame(effect(term = "funday", mod = dogs_fun_day_BSC_,
xlevels = list(funday = seq(min(threat_data__scaled_BSC[, "funday"], na.rm = TRUE), max(threat_data__scaled_BSC[, "funday"], na.rm = TRUE), 1)))) %>%
mutate(region = "BSC")
dogs_fun_day__fits <-
bind_rows(dogs_fun_day_FP__fits,
dogs_fun_day_MP__fits,
dogs_fun_day_BSC__fits) %>%
mutate(funday = ifelse(funday == 0, "no", "yes"))
row.names(dogs_fun_day__fits) <- NULL
ggplot() +
geom_line(data = dogs_fun_day__fits,
aes(x = funday, y = fit, color = region, group = region),
position = position_dodge(width = 0.5), alpha = 0.2, size = 2) +
geom_errorbar(data = dogs_fun_day__fits,
aes(ymin = lower, ymax = upper,
x = funday,
y = fit, group = region), position = position_dodge(width = 0.5),
alpha = 0.5, color = "black", width = 0.3, lwd = 0.5) +
geom_point(data = dogs_fun_day__fits,
aes(x = funday, y = fit, fill = region),
shape = 21, size = 4, position = position_dodge(width = 0.5)) +
luke_theme +
theme(legend.position = "top",
legend.justification = c(1, 0),
strip.background = element_blank(),
axis.title.x = element_blank(),
axis.text.x = element_text(size = 10)) +
ylab("number of dogs detected (± 95% CI)") +
scale_colour_brewer(palette = "Dark2",
name = "Region",
labels = c("Bellarine/Surf Coast", "Fleurieu Peninsula", "Mornington Peninsula")) +
scale_fill_brewer(palette = "Dark2",
name = "Region",
labels = c("Bellarine/Surf Coast", "Fleurieu Peninsula", "Mornington Peninsula")) +
scale_x_discrete(labels = c("weekday", "weekend/holiday"))strong relationship between the number of dogs off leash detected and the occurrence of a weekend or a holiday at all 3 regions
dogs_off_fun_day_FP_ <-
glmer(dogs_off_ ~
poly(obs_date2, 3) +
funday + (1 | season) + (1 | site),
data = threat_data__scaled_FP,
family = "poisson")
dogs_off_fun_day_MP_ <-
glmer(dogs_off_ ~
poly(obs_date2, 3) +
funday + (1 | season) + (1 | site),
data = threat_data__scaled_MP,
family = "poisson")
dogs_off_fun_day_BSC_ <-
glmer(dogs_off_ ~
poly(obs_date2, 3) +
funday + (1 | season) + (1 | site),
data = threat_data__scaled_BSC,
family = "poisson")Fleurieu Peninsula
tbl_regression(dogs_off_fun_day_FP_, intercept = TRUE,
label = list(obs_date2 ~ "Date", funday ~ "Weekends & Holidays"))| Characteristic | log(IRR)1 | 95% CI1 | p-value |
|---|---|---|---|
| (Intercept) | -1.7 | -2.1, -1.2 | <0.001 |
| Date | |||
| Date | 3.0 | 1.1, 4.9 | 0.002 |
| Date² | 4.6 | 2.7, 6.6 | <0.001 |
| Date³ | -8.9 | -11, -6.9 | <0.001 |
| Weekends & Holidays | 0.23 | 0.20, 0.26 | <0.001 |
| 1 IRR = Incidence Rate Ratio, CI = Confidence Interval | |||
Mornington Peninsula
tbl_regression(dogs_off_fun_day_MP_, intercept = TRUE,
label = list(obs_date2 ~ "Date", funday ~ "Weekends & Holidays"))| Characteristic | log(IRR)1 | 95% CI1 | p-value |
|---|---|---|---|
| (Intercept) | -3.3 | -3.9, -2.8 | <0.001 |
| Date | |||
| Date | -2.8 | -9.6, 4.0 | 0.4 |
| Date² | -0.04 | -7.0, 6.9 | >0.9 |
| Date³ | 0.35 | -6.3, 7.0 | >0.9 |
| Weekends & Holidays | 0.51 | 0.40, 0.62 | <0.001 |
| 1 IRR = Incidence Rate Ratio, CI = Confidence Interval | |||
Bellarine / Surf Coast
tbl_regression(dogs_off_fun_day_BSC_, intercept = TRUE,
label = list(obs_date2 ~ "Date", funday ~ "Weekends & Holidays"))| Characteristic | log(IRR)1 | 95% CI1 | p-value |
|---|---|---|---|
| (Intercept) | -0.74 | -1.1, -0.38 | <0.001 |
| Date | |||
| Date | -1.1 | -3.9, 1.6 | 0.4 |
| Date² | 7.5 | 4.8, 10 | <0.001 |
| Date³ | -0.19 | -2.8, 2.4 | 0.9 |
| Weekends & Holidays | 0.48 | 0.41, 0.54 | <0.001 |
| 1 IRR = Incidence Rate Ratio, CI = Confidence Interval | |||
dogs_off_fun_day_FP__fits <-
as.data.frame(effect(term = "funday", mod = dogs_off_fun_day_FP_,
xlevels = list(funday = seq(min(threat_data__scaled_FP[, "funday"], na.rm = TRUE), max(threat_data__scaled_FP[, "funday"], na.rm = TRUE), 1)))) %>%
mutate(region = "FP")
dogs_off_fun_day_MP__fits <-
as.data.frame(effect(term = "funday", mod = dogs_off_fun_day_MP_,
xlevels = list(funday = seq(min(threat_data__scaled_MP[, "funday"], na.rm = TRUE), max(threat_data__scaled_MP[, "funday"], na.rm = TRUE), 1)))) %>%
mutate(region = "MP")
dogs_off_fun_day_BSC__fits <-
as.data.frame(effect(term = "funday", mod = dogs_off_fun_day_BSC_,
xlevels = list(funday = seq(min(threat_data__scaled_BSC[, "funday"], na.rm = TRUE), max(threat_data__scaled_BSC[, "funday"], na.rm = TRUE), 1)))) %>%
mutate(region = "BSC")
dogs_off_fun_day__fits <-
bind_rows(dogs_off_fun_day_FP__fits,
dogs_off_fun_day_MP__fits,
dogs_off_fun_day_BSC__fits) %>%
mutate(funday = ifelse(funday == 0, "no", "yes"))
row.names(dogs_off_fun_day__fits) <- NULL
ggplot() +
geom_line(data = dogs_off_fun_day__fits,
aes(x = funday, y = fit, color = region, group = region),
position = position_dodge(width = 0.5), alpha = 0.2, size = 2) +
geom_errorbar(data = dogs_off_fun_day__fits,
aes(ymin = lower, ymax = upper,
x = funday,
y = fit, group = region), position = position_dodge(width = 0.5),
alpha = 0.5, color = "black", width = 0.3, lwd = 0.5) +
geom_point(data = dogs_off_fun_day__fits,
aes(x = funday, y = fit, fill = region),
shape = 21, size = 4, position = position_dodge(width = 0.5)) +
luke_theme +
theme(legend.position = "top",
legend.justification = c(1, 0),
strip.background = element_blank(),
axis.title.x = element_blank(),
axis.text.x = element_text(size = 10)) +
ylab("number of dogs off leash detected (± 95% CI)") +
scale_colour_brewer(palette = "Dark2",
name = "Region",
labels = c("Bellarine/Surf Coast", "Fleurieu Peninsula", "Mornington Peninsula")) +
scale_fill_brewer(palette = "Dark2",
name = "Region",
labels = c("Bellarine/Surf Coast", "Fleurieu Peninsula", "Mornington Peninsula")) +
scale_x_discrete(labels = c("weekday", "weekend/holiday"))weak negative relationship at Fleurieu Peninsula and Mornington Peninsula between the number of corvids detected and the occurrence of a weekend or a holiday
pred_birds_fun_day_FP_ <-
glmer(pred_birds_ ~
poly(obs_date2, 3) +
funday + (1 | season) + (1 | site),
data = threat_data__scaled_FP,
family = "poisson")
pred_birds_fun_day_MP_ <-
glmer(pred_birds_ ~
poly(obs_date2, 3) +
funday + (1 | season) + (1 | site),
data = threat_data__scaled_MP,
family = "poisson")
pred_birds_fun_day_BSC_ <-
glmer(pred_birds_ ~
poly(obs_date2, 3) +
funday + (1 | season) + (1 | site),
data = threat_data__scaled_BSC,
family = "poisson")Fleurieu Peninsula
tbl_regression(pred_birds_fun_day_FP_, intercept = TRUE,
label = list(obs_date2 ~ "Date", funday ~ "Weekends & Holidays"))| Characteristic | log(IRR)1 | 95% CI1 | p-value |
|---|---|---|---|
| (Intercept) | -1.2 | -1.4, -0.86 | <0.001 |
| Date | |||
| Date | -3.8 | -7.8, 0.16 | 0.060 |
| Date² | -24 | -28, -20 | <0.001 |
| Date³ | 6.3 | 2.3, 10 | 0.002 |
| Weekends & Holidays | -0.15 | -0.20, -0.10 | <0.001 |
| 1 IRR = Incidence Rate Ratio, CI = Confidence Interval | |||
Mornington Peninsula
tbl_regression(pred_birds_fun_day_MP_, intercept = TRUE,
label = list(obs_date2 ~ "Date", funday ~ "Weekends & Holidays"))| Characteristic | log(IRR)1 | 95% CI1 | p-value |
|---|---|---|---|
| (Intercept) | -2.1 | -2.4, -1.8 | <0.001 |
| Date | |||
| Date | 13 | 7.8, 19 | <0.001 |
| Date² | -47 | -52, -41 | <0.001 |
| Date³ | 21 | 15, 27 | <0.001 |
| Weekends & Holidays | -0.21 | -0.29, -0.14 | <0.001 |
| 1 IRR = Incidence Rate Ratio, CI = Confidence Interval | |||
Bellarine / Surf Coast
tbl_regression(pred_birds_fun_day_BSC_, intercept = TRUE,
label = list(obs_date2 ~ "Date", funday ~ "Weekends & Holidays"))| Characteristic | log(IRR)1 | 95% CI1 | p-value |
|---|---|---|---|
| (Intercept) | -1.7 | -2.1, -1.3 | <0.001 |
| Date | |||
| Date | 0.86 | -4.4, 6.1 | 0.7 |
| Date² | -38 | -43, -32 | <0.001 |
| Date³ | 8.8 | 2.7, 15 | 0.005 |
| Weekends & Holidays | -0.09 | -0.17, -0.01 | 0.022 |
| 1 IRR = Incidence Rate Ratio, CI = Confidence Interval | |||
pred_birds_fun_day_FP__fits <-
as.data.frame(effect(term = "funday", mod = pred_birds_fun_day_FP_,
xlevels = list(funday = seq(min(threat_data__scaled_FP[, "funday"], na.rm = TRUE), max(threat_data__scaled_FP[, "funday"], na.rm = TRUE), 1)))) %>%
mutate(region = "FP")
pred_birds_fun_day_MP__fits <-
as.data.frame(effect(term = "funday", mod = pred_birds_fun_day_MP_,
xlevels = list(funday = seq(min(threat_data__scaled_MP[, "funday"], na.rm = TRUE), max(threat_data__scaled_MP[, "funday"], na.rm = TRUE), 1)))) %>%
mutate(region = "MP")
pred_birds_fun_day_BSC__fits <-
as.data.frame(effect(term = "funday", mod = pred_birds_fun_day_BSC_,
xlevels = list(funday = seq(min(threat_data__scaled_BSC[, "funday"], na.rm = TRUE), max(threat_data__scaled_BSC[, "funday"], na.rm = TRUE), 1)))) %>%
mutate(region = "BSC")
pred_birds_fun_day__fits <-
bind_rows(pred_birds_fun_day_FP__fits,
pred_birds_fun_day_MP__fits,
pred_birds_fun_day_BSC__fits) %>%
mutate(funday = ifelse(funday == 0, "no", "yes"))
row.names(pred_birds_fun_day__fits) <- NULL
ggplot() +
geom_line(data = pred_birds_fun_day__fits,
aes(x = funday, y = fit, color = region, group = region),
position = position_dodge(width = 0.5), alpha = 0.2, size = 2) +
geom_errorbar(data = pred_birds_fun_day__fits,
aes(ymin = lower, ymax = upper,
x = funday,
y = fit, group = region), position = position_dodge(width = 0.5),
alpha = 0.5, color = "black", width = 0.3, lwd = 0.5) +
geom_point(data = pred_birds_fun_day__fits,
aes(x = funday, y = fit, fill = region),
shape = 21, size = 4, position = position_dodge(width = 0.5)) +
luke_theme +
theme(legend.position = "top",
legend.justification = c(1, 0),
strip.background = element_blank(),
axis.title.x = element_blank(),
axis.text.x = element_text(size = 10)) +
ylab("number of magpies and ravens detected (± 95% CI)") +
scale_colour_brewer(palette = "Dark2",
name = "Region",
labels = c("Bellarine/Surf Coast", "Fleurieu Peninsula", "Mornington Peninsula")) +
scale_fill_brewer(palette = "Dark2",
name = "Region",
labels = c("Bellarine/Surf Coast", "Fleurieu Peninsula", "Mornington Peninsula")) +
scale_x_discrete(labels = c("weekday", "weekend/holiday"))negative relationship (albeit only significant at Mornington Peninsula) between the number of corvids detected and the occurrence of a weekend or a holiday
gulls_fun_day_FP_ <-
glmer(gulls_ ~
poly(obs_date2, 3) +
funday + (1 | season) + (1 | site),
data = threat_data__scaled_FP,
family = "poisson")
gulls_fun_day_MP_ <-
glmer(gulls_ ~
poly(obs_date2, 3) +
funday + (1 | season) + (1 | site),
data = threat_data__scaled_MP,
family = "poisson")
gulls_fun_day_BSC_ <-
glmer(gulls_ ~
poly(obs_date2, 3) +
funday + (1 | season) + (1 | site),
data = threat_data__scaled_BSC,
family = "poisson")Fleurieu Peninsula
tbl_regression(gulls_fun_day_FP_, intercept = TRUE,
label = list(obs_date2 ~ "Date", funday ~ "Weekends & Holidays"))| Characteristic | log(IRR)1 | 95% CI1 | p-value |
|---|---|---|---|
| (Intercept) | -1.0 | -1.3, -0.68 | <0.001 |
| Date | |||
| Date | 3.8 | 0.33, 7.2 | 0.032 |
| Date² | -29 | -33, -25 | <0.001 |
| Date³ | 4.6 | 0.92, 8.3 | 0.014 |
| Weekends & Holidays | -0.07 | -0.12, -0.03 | <0.001 |
| 1 IRR = Incidence Rate Ratio, CI = Confidence Interval | |||
Mornington Peninsula
tbl_regression(gulls_fun_day_MP_, intercept = TRUE,
label = list(obs_date2 ~ "Date", funday ~ "Weekends & Holidays"))| Characteristic | log(IRR)1 | 95% CI1 | p-value |
|---|---|---|---|
| (Intercept) | -2.0 | -2.4, -1.7 | <0.001 |
| Date | |||
| Date | 17 | 11, 22 | <0.001 |
| Date² | -59 | -65, -53 | <0.001 |
| Date³ | 30 | 24, 36 | <0.001 |
| Weekends & Holidays | -0.31 | -0.38, -0.25 | <0.001 |
| 1 IRR = Incidence Rate Ratio, CI = Confidence Interval | |||
Bellarine / Surf Coast
tbl_regression(gulls_fun_day_BSC_, intercept = TRUE,
label = list(obs_date2 ~ "Date", funday ~ "Weekends & Holidays"))| Characteristic | log(IRR)1 | 95% CI1 | p-value |
|---|---|---|---|
| (Intercept) | -1.5 | -2.0, -1.0 | <0.001 |
| Date | |||
| Date | 5.1 | 1.0, 9.2 | 0.015 |
| Date² | -41 | -46, -36 | <0.001 |
| Date³ | -2.8 | -7.7, 2.2 | 0.3 |
| Weekends & Holidays | -0.21 | -0.27, -0.15 | <0.001 |
| 1 IRR = Incidence Rate Ratio, CI = Confidence Interval | |||
gulls_fun_day_FP__fits <-
as.data.frame(effect(term = "funday", mod = gulls_fun_day_FP_,
xlevels = list(funday = seq(min(threat_data__scaled_FP[, "funday"], na.rm = TRUE), max(threat_data__scaled_FP[, "funday"], na.rm = TRUE), 1)))) %>%
mutate(region = "FP")
gulls_fun_day_MP__fits <-
as.data.frame(effect(term = "funday", mod = gulls_fun_day_MP_,
xlevels = list(funday = seq(min(threat_data__scaled_MP[, "funday"], na.rm = TRUE), max(threat_data__scaled_MP[, "funday"], na.rm = TRUE), 1)))) %>%
mutate(region = "MP")
gulls_fun_day_BSC__fits <-
as.data.frame(effect(term = "funday", mod = gulls_fun_day_BSC_,
xlevels = list(funday = seq(min(threat_data__scaled_BSC[, "funday"], na.rm = TRUE), max(threat_data__scaled_BSC[, "funday"], na.rm = TRUE), 1)))) %>%
mutate(region = "BSC")
gulls_fun_day__fits <-
bind_rows(gulls_fun_day_FP__fits,
gulls_fun_day_MP__fits,
gulls_fun_day_BSC__fits) %>%
mutate(funday = ifelse(funday == 0, "no", "yes"))
row.names(gulls_fun_day__fits) <- NULL
ggplot() +
geom_line(data = gulls_fun_day__fits,
aes(x = funday, y = fit, color = region, group = region),
position = position_dodge(width = 0.5), alpha = 0.2, size = 2) +
geom_errorbar(data = gulls_fun_day__fits,
aes(ymin = lower, ymax = upper,
x = funday,
y = fit, group = region), position = position_dodge(width = 0.5),
alpha = 0.5, color = "black", width = 0.3, lwd = 0.5) +
geom_point(data = gulls_fun_day__fits,
aes(x = funday, y = fit, fill = region),
shape = 21, size = 4, position = position_dodge(width = 0.5)) +
luke_theme +
theme(legend.position = "top",
legend.justification = c(1, 0),
strip.background = element_blank(),
axis.title.x = element_blank(),
axis.text.x = element_text(size = 10)) +
ylab("number of gulls detected (± 95% CI)") +
scale_colour_brewer(palette = "Dark2",
name = "Region",
labels = c("Bellarine/Surf Coast", "Fleurieu Peninsula", "Mornington Peninsula")) +
scale_fill_brewer(palette = "Dark2",
name = "Region",
labels = c("Bellarine/Surf Coast", "Fleurieu Peninsula", "Mornington Peninsula")) +
scale_x_discrete(labels = c("weekday", "weekend/holiday"))